I need to use the input which is a string to "identify" an already declared variable. If "tripple" is inputted than java need to somehow get that the variable tripple is meaned by the input "tripple". I am doing that because I need to add its value(3, because int tripple = 3) to another variable(Integer).
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner();
int double = 2
int tripple = 3
int startpos = 0
String inputting = scan.next(); //input is for example ---> tripple
startpos = startpos + (???)
//After inputting "tripple", startpos should be 3
System.out.println(startpos); //---> 3
}
}
I tried to get an input and adress the variable that has the same name as the input which is a string. I didn't know what to do, so I asked my teacher and she also do not know what to do so I am asking it to you.