System.out.print(">> ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();
I would like to name a variable (double input=new double[5];) with the name the program gets from BufferedReader. How to do that?
You can't do it. Variable are defined at compile-time. And you don't need it - how would you access variables with dynamic names?
You can use a Map<String, double[]> to map a string to a double array. map.put(name, array) and then map.get(name) will give you the array.
No, you can't. It would be equivalent of changing the source code at run-time. Why do you need to do this, anyway?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With