using string value as a variable name
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi All,
How to convert a string into variable name. For example i have a variable named "myname" with value "sachin" in it i.e myname="sachin".
Then in an string i have a name of the variable. using this strings value how to print the name sachin. i.e if myString = "myname" how to print "sachin" using this string variable?
eg code:
myname = "sachin";
String myString = "myname";
i want out.println(myString) to print "sachin".
Thanks in advance for ur help.
Bye,
B.Prakash.
How to convert a string into variable name. For example i have a variable named "myname" with value "sachin" in it i.e myname="sachin".
Then in an string i have a name of the variable. using this strings value how to print the name sachin. i.e if myString = "myname" how to print "sachin" using this string variable?
eg code:
myname = "sachin";
String myString = "myname";
i want out.println(myString) to print "sachin".
Thanks in advance for ur help.
Bye,
B.Prakash.
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Print where?
stdout?
The webpage?
stdout?
The webpage?
Prakash Balasubramani
Greenhorn
Posts: 8
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I want to print it in WebPage
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
i hope it helps
StringBuffer myname = new StringBuffer();
name.append("sachin");
StringBuffer mystring = myname;
out.println(ename.toString());
StringBuffer myname = new StringBuffer();
name.append("sachin");
StringBuffer mystring = myname;
out.println(ename.toString());
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
String myname = "sachin";
String myString = myname; // get rid of the quotes so that you set myString equal to the value of myname, instead of setting myString equal to myname.
out.println(myString);
String myString = myname; // get rid of the quotes so that you set myString equal to the value of myname, instead of setting myString equal to myname.
out.println(myString);
| I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |











