java - Getters returning null -
I know why my problem is happening but I have uncertainty about how to deal with it.
So I have 3 classes, 1 of these are my Gates & amp; Setters In one class I am setting the price and in the second I am getting the values. When I get the value, they are returned empty. It is clearly because two examples of meeting / setter objects created in classes are different from each other. What am I trying to find out how can I set prices in a class and get them in two without the different examples of the Gater / Setter Class. My word is terrible, so here's a more detailed explanation:
Class 1 class 2 Class 3 (Encapsulation) In class 2, New example of charge (new fusion (notice)) So obviously, he will not mind. Instead, I will suggest two solutions to you: First: Save the object in the object as you would see an Android application Are working on Now in your activity: You must register your application class in your manifest file as if you register your activities: Second: Put the object encrypt as 1 static. So you can access it from calss2. (I do not like stagnant.) Hope it helps.
Encapsulation encap = new Encapsulation (); Encap.setValue (10);
encapsulation NAPP = new addition (); Encap.getValue (); // I have to return this 10
private int value; Public Zero Set Value (int value) {this.value = value; } Public int getValue () {return value}
Extends the public class test applications application {Public Incomplete Temp Class; Public Trial Application (TODO Auto-generated Constructor Stub} @ Override Public Wide On Create () {// TODO Auto-Generated Method Stub Super. Connet (); } Public Encapsulation getTempClass () {Return tempClass; } Public Zero set template (encapsulation temp class) {this.tempClass = tempClass; }}
// after setting contentView testAppObj = (testing app) getApplication (); TestAppObj.setTempClass (myTempClassObj); // Recover: Encapsulation obj = testAppObj.getTempClass ();
Comments
Post a Comment