Created
February 24, 2019 09:21
-
-
Save priesdelly/5f0d8582a7fa85090b40953b95deed01 to your computer and use it in GitHub Desktop.
Example static variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
public class TestStaticVariable { | |
public static void main(String[] args) { | |
ArrayList < TestModel > modelLst = new ArrayList < > (); | |
for (int i = 0; i < 10; i++) { | |
TestModel model = new TestModel(); | |
model.setValue1(i); | |
model.setValue2(i); | |
modelLst.add(model); | |
} | |
for (int i = 0; i < 10; i++) { | |
TestModel model = modelLst.get(i); | |
int value1 = model.getValue1(); | |
int value2 = model.getValue2(); | |
System.out.println("Value 1 : " + value1 + " Value 2 : " + value2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment