What is the output of the following Java program?
package test; import java.util.*; class Main { public static void main(String[] argh) { StringTokenizer st = new StringTokenizer("{5A=1500,2B=1950,5A=1000,3C=1770}", ("{=,}")); Map hm = new HashMap(); while (st.hasMoreTokens()) { hm.put(st.nextToken(), st.nextToken()); } System.out.println(hm.toString()); } }
The given java program is :
import java.util.*;
class Main {
public static void main(String[] argh) {
StringTokenizer st = new StringTokenizer("{5A=1500,2B=1950,5A=1000,3C=1770}", ("{=,}"));
Map hm = new HashMap();
while (st.hasMoreTokens()) {
hm.put(st.nextToken(), st.nextToken());
}
System.out.println(hm.toString());
}
}
So, the output of the above java program is :
{2B=1950, 3C=1770, 5A=1000}
What is the output of the following Java program? package test; import java.util.*; class Main {...