Forums Register Login

About access to relevant variables from variable name

+Pie Number of slices to send: Send
Hello,Now, I want to get this variable name according to the variable,

Otherwise, can to do write

Do not know with what method can be finished,Because it is in the method inside,So can't use reflection to complete his,
Thanks
+Pie Number of slices to send: Send
Beginning Java question. Moving...
+Pie Number of slices to send: Send
I am not at all sure I understand the question. I would prefer to use loops, myself. You can of course get the String values from the loops, too.I presume that Map is a field, so it will remain in scope.
+Pie Number of slices to send: Send
Basically, you can't. If you want to be able to map strings to objects then a better approach is to use a Map from String to whatever type of object you want. It's a little difficult to demonstrate that in this example, because it's not clear what the point is.
+Pie Number of slices to send: Send
You might even consider using an array, instead of five named variables. But like Matthew suggests, it's pretty hard to say what you should do when the code in question is meaningless.
+Pie Number of slices to send: Send
 

Paul Clapham wrote:Beginning Java question. Moving...


thank you,I've been thinking about which one should be in the area,But still wrong,Thank you for correcting me!



+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:I am not at all sure I understand the question. I would prefer to use loops, myself. You can of course get the String values from the loops, too.I presume that Map is a field, so it will remain in scope.


Hello,Campbell
Maybe I express way let you misunderstood, i flet very sorry !
I think you write only for content of the same code format,
If is the

,Then use this method is not very good,but you gave me the enlightenment,


use a 2d array,through the subscript obtain values !
Thank you,but my friend said a 2d array impact performance,Dont't know what you think about that ?

+Pie Number of slices to send: Send
 

Paul Clapham wrote:You might even consider using an array, instead of five named variables. But like Matthew suggests, it's pretty hard to say what you should do when the code in question is meaningless.


Hello, Paul,
I think is the ellipsis added code,It's like this


Only add once,yes ,i used the array !
+Pie Number of slices to send: Send
 

Jerome Gao wrote: . . .


use a 2d array,through the subscript obtain values !

There is no such thing as a 2D array. Only an array of arrays.

I still don’t understand why you insist on doing something by hand which the computer will do for you automatically.


Thank you,but my friend said a 2d array impact performance,Don't know what you think about that ?

Your friend is mistaken. Array access is very very fast.
I brought this back from the farm where they grow the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 659 times.
Similar Threads
Can not Populate the form on combo box change
MultiDimenaional Array sort
CODE: Dynamic Sorting on Multiple Indexes
JSP attendance management project error
iterating with a scriptlet, can't get the values into js arr
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:14:55.