how do I get the class that an object is being accessed from in java? -


public class object0{     object classbeingaccessedfrom = ?;      public static void getnumber(){         return classbeingaccessedfrom.width/classbeingaccessedfrom.height;     } } public class object1{     public static int width = 500;     public static int height = 500;      public static void main(string[] args){         system.out.println(object0.getnumber());     } } public class object2{     public static int width = 400;     public static int height = 600;       public static void main(string[] args){         system.out.println(object0.getnumber());     }  } 

is possible able tell class object being accessed from? when working on making easy use vector3f class, needed way able perceive width , height screen perspective projection. there way how tell class accessing vector3f object, solve problem.

as mentioned in comments:

public class object0{      public static void getnumber(int width, int height){         return width/height;     } } public class object1{     public static int width = 500;     public static int height = 500;      public static void main(string[] args){         system.out.println(object0.getnumber(width, height));     } } public class object2{     public static int width = 400;     public static int height = 600;       public static void main(string[] args){         system.out.println(object0.getnumber(width, height));     }  } 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -