java - How can I define a variable within an object with another variable -


the title might little confusing want know how can change ' b ' part in mainsave.b define within object.

here code far

public void getitem(int a, string b) {     mainsave.b = a; } 

the values being sent piece of code in class called story. want them stored in object of class savefile 'mainsave' is

if (command_string.equals("1"))         {            try {thread.sleep(1500);} catch (interruptedexception e) {}             system.out.println("you search shed thouroughly , find axe not else...");            int item = 1;            string axe = "axe";            getitem(item,axe);            try {thread.sleep(1500);} catch (interruptedexception e) {}               area1();         } 

the error when trying compile first part "cannot find symbol - variable b"

simply cannot since java statically typed language. variables names must realize @ compile time.

i don't suggest possible reflection coding.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -