public static HashMap<Character,Double> symbols = new HashMap<>();
public static void getSymbol() {
char ch = ' ';
double pro;
while (ch!='`') {
Scanner scanner = new Scanner(System.in);
System.out.println("Input the character");
ch = scanner.next().charAt(0);
if (ch == '`')break;
Scanner num = new Scanner(System.in);
pro = num.nextDouble();
symbols.put(ch, pro);
}
System.out.println(symbols);
}
}
when I input a,b,c,q
in this particular order
the output of HashMap
will be : a,q,b,c