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

  Encapsulation encap = new Encapsulation (); Encap.setValue (10);   

class 2

  encapsulation NAPP = new addition (); Encap.getValue (); // I have to return this 10   

Class 3 (Encapsulation)

  private int value; Public Zero Set Value (int value) {this.value = value; } Public int getValue () {return value}    

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

  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; }}   

Now in your activity: // after setting contentView testAppObj = (testing app) getApplication (); TestAppObj.setTempClass (myTempClassObj); // Recover: Encapsulation obj = testAppObj.getTempClass ();

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.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -