java - Object Instance Manipulation -


If I have an object instance, say A4, can I print the name of this example like this? ?

Then with example a4, I will say my output a4.

The simple answer is; If you want an object, give it a name field and add this field to toString ()


local variables only one The debug info of the method is available in. It is possible to read a byte code of a method and reverse engineer is a name but extraordinary work is required for it.

Consider

  object a1 = ... object b1 = a1;  

The same object has been referred to by two local variables. Any object can be referenced in any number, eg. Empty string object is often the most referenced object in the Java program. This can be displayed in 10K locations in a general program.


I am trying to add an array for a Hashmap which only takes a Hashmap key I take, already remove an array in the hashmap, its a clone And then use that clash as the name of that key in the hashmap.

You can pass the array in a method like this:

  Public Zero addArray (int ... array) { 

The reference to the array at this point is "name" array and it will not make any difference.

You need to have the name you want to have for the array because the caller has no way of knowing that Kaili was used as a local variable. Often there is no name in the first place of one variable.

  addArray (1, 2, 3);  

or

  addArray (count (number) ());  

or

  int [] nums = {1, 2, 3}; AddArray (nums);  

Note: nums is not really required because local variables can be removed. That is, a good chance nums will not even be present at the runtime.


What you need to do

  Public Zero AddArray (string name, int ... array) {map.put (name, array); }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -