Linked Questions

11 votes
2 answers
22k views

is possible get variable name? For example: String nameOfCar = "audi"; Now print the result: System.out.println(nameOfCar.getVname???or something similar); Screen: nameOfCar
user3784463's user avatar
3 votes
2 answers
14k views

Possible Duplicate: Java Reflection: How to get the name of a variable? I've found various discussions on this topic but never any satisfying answer.. A anyVariableName = new A(); How can I get ...
Wally_the_Walrus's user avatar
6 votes
4 answers
2k views

What would be the equivalent in java of C++ code: #define printVar(var) cout<<#var<<"="<<var; printing string value and its name .
repo's user avatar
  • 760
1 vote
2 answers
4k views

I'm facing following problem: I have to give names to many thousands of GUI-Elements. Would be nice if it could work a script like: JMenuItem myMenuItem = new JMenuItem(); myMenuItem .setName(this....
SWYM's user avatar
  • 53
0 votes
2 answers
362 views

I'm using a ContentResolver query to get some data from a database in Android. That's not the issue. The method returns string representation of integers, INT TYPE_MAIN = 2 I want to convert that to ...
Ozair Patel's user avatar
  • 1,956
0 votes
1 answer
172 views

String getName(Object o) { //TODO } String object = "i want to get "object" not these words" getName(object); Is it possible the method return "object"? thx
user2539662's user avatar
0 votes
1 answer
116 views

i want to display only the variable name not the value let's say String x='abc'; i want my output to be x notabc don't want to create a code like this System.out.println('x') i want dynamicaly save ...
Bahy Mohamed's user avatar
0 votes
2 answers
124 views

In my application, i want to print out a variable´s value AND its name, if possible. For example: int testinteger = 0; String type = > type of testinteger? (int); String name = > name of ...
Gary Klasen's user avatar
  • 1,070
0 votes
0 answers
86 views

How can i print variable name in Java? Example: String variableString = "some string"; System.out.println(variableName); Expected result in console: "variableString" I need this for logging for ...
Anton_Selenium's user avatar
0 votes
0 answers
59 views

I need to get the Object name from .display() function like "faruq unique id is blabla".. Is it possible? Is there any method to make it happen? public class Login { String uniqueID; public ...
Farooque Sher's user avatar
0 votes
2 answers
93 views

how do I print objects name randomly, for instance: skeleton, zombie or assassin ? but all of em have used on class only Enemies ? For example, I have: Enemies skeleton = new Enemies(100, 20); ...
Bakai Ismailov's user avatar
0 votes
0 answers
48 views

Is it possible to return the name you gave to a Rectangle object when you created it? For example: Rectangle f = new Rectangle(); f.getName() \\would return "f"
Cora Coleman's user avatar
27 votes
3 answers
30k views

I have a Kotlin class in my application with a lot of attributes, what I want to build is a method that stores the variable name in a dictionary. The dictionary looks like this: HashMap<String, ...
user avatar
18 votes
4 answers
61k views

I have a 2 POJO classes with getters and setters,now i am trying to get all the class instance variables of that class. I got to know that we can use reflection how to do it? This is my POJO Class ...
Goofy's user avatar
  • 6,128
14 votes
12 answers
49k views

EDIT: I would love to read reactions to Steve Reed's AOP approach. Comments to his answer are encouraged! I'm a novice, and at some point I realized it would be helpful to know the contents of a ...
Lasoldo Solsifa's user avatar

15 30 50 per page
1
2 3 4 5