Perfil

Data de entrada: 18 de mai. de 2022

Sobre

Wp Job Manager Nulled 23 --> DOWNLOAD


Wp Job Manager Nulled 23 --> DOWNLOAD







Q: Manual instantiation of class using pointer to a static object of same class - JAVA I am having a hard time wrapping my head around this concept. I have a situation where I need to instantiate a class using a pointer. The pointer has to point to a static object of the same type as the class. I need to do this because I have two different classes that are acting as containers of different data. Here's an example: public class Test { private String data1; private String data2; public Test() { data1 = "testdata1"; data2 = "testdata2"; } public void printData() { System.out.println(data1); System.out.println(data2); } public static void main(String[] args) { Test test = new Test(); test.printData(); } } class Container { private String data1; private String data2; public Container() { data1 = "testdata1"; data2 = "testdata2"; } public void printData() { System.out.println(data1); System.out.println(data2); } } This is what I have currently, but it is not working because in the example above, data1 and data2 are static members of the class Test. However, in the real situation, the classes are different and I need to pass the class name along to the constructor. Container container = new Container(Test.class.getClass().getName()); A: The code you posted creates a reference to an instance of the class. That instance is a copy of the Test instance and is still






ee43de4aa9

Wp Job Manager Nulled 23

Mais ações