-1

In Java, let's say I have...

let hello = 10;

Is it possible to retrieve hello's value (10) using the string reference 'hello'? Something like valueOf(....'hello'....) = 10

user1488934
  • 247
  • 2
  • 5
  • 13
  • 2
    It is very unlikely that you have a class called `let` (which does not conform to the Java naming conventions) that can be assigned an integer. Is your question about [tag:javascript]? – Johannes Kuhn Jan 11 '23 at 06:33
  • This may not be a duplicate. It may be a misunderstanding as pointed out by @JohannesKuhn. – SedJ601 Jan 11 '23 at 06:36
  • sorry for the misunderstanding, it is Javascript / Google Script. What I need to do is use the string 'hello' to return the variable of the same name, surely this possible? – user1488934 Jan 11 '23 at 22:34

1 Answers1

-2

This is how you can retrive in Java. Also let is used in JavaScript not in Java.

public class Test {

    public static void main(String[] args) {
        String hello = "10";
        int helloNum = Integer.valueOf(hello); //converting String "10" into int 10
        
        
        int num = 10;
        String numString = String.valueOf(num);//converting int 10 to string "10"
        
    }
}