看下面的代码 ,我想查看对象x的地址,以及x的方法getA,getB,以及属性a,b的地址,我如何可以取到?   
 
package  test;  
 
   
public  class  AClass  {  
 public  String  a;  
   
 public  Object  b;  
 public  AClass(){  
   this.a=  "tt";//与  new  String  ("ttt");结果完全不一样。  
   this.b=  new  Object();  
 }  
   
 public  String  getA(){return  a;}  
 public  Object  getB(){return  b;}  
 
 
 /**  
   *  @param  args  
   */  
 public  static  void  main(String[]  args)  {  
   //  TODO  Auto-generated  method  stub  
     
   AClass  x  =  new  AClass();  
   //我想查看对象x的地址,以及x的方法getA,getB,以及属性a,b的地址,我如何可以取到?  
 }  
 
}  

解决方案 »

  1.   

    java里没有这些概念,他并不像C++程序,什么都有个地址,有方法指针就可以调用方法。
      

  2.   

    没有地址,否则Java的很多安全性就不能得到保证了!
      

  3.   

    我觉得也只能通过取得hashcode来表示其地址了。
    As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
    这个市官方文档上的一段话,也许对你有帮助。
      

  4.   

    那一个CLASS的多个实例,函数地址是不是一样的呢?
      

  5.   

    一个CLASS的多个实例,地址是不一样的吧.
      

  6.   

    其实对于java来说,根本没必要考虑这些问题!
    我也是菜鸟级的,但是我认为这可能跟JVM的实现有关吧,同一段程序在不同的JVM下可能分配的地址也会不同!比如在windows平台和Linux平台可能就不一样!
      

  7.   

    没有地址,否则Java的很多安全性就不能得到保证了!