What is the output of the following Java program? — Selenium and Java Challenge 2

I have started a 30-day Selenium with Java challenge to help beginners and intermediate software testers for learning Selenium and Java concepts. This is the second challenge i have posted. Share your answers in the comments about the program’s output—I’ll provide my short answer afterward.

import java.util.HashMap;
import org.testng.annotations.Test;

import java.util.Map;

public class SampleProgram2 {

@Test
public void testMySkills() {
    System.out.println(getMappedItem());
}

public int getMappedItem() {
    HashMap<Integer,Integer> map = new HashMap<>();
    map.put(5,10);
    map.put(9,11);
    map.put(2,12);

    int i = 0;
    for (Map.Entry<Integer,Integer> set:map.entrySet()) {
        set.setValue(set.getValue()*10);
    }
    return map.get(5);
}

}

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Testingtalkslatest.com - A project by CreativeHub IT Solutions.
Contact Us At: support@testingtalkslatest.com
Our Partner websites - Classified Hub , CodesToolbox , CodesToolbox
Scroll to Top
0
Would love your thoughts, please comment.x
()
x