Skip to content

Instantly share code, notes, and snippets.

@priesdelly
Created February 24, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save priesdelly/5f0d8582a7fa85090b40953b95deed01 to your computer and use it in GitHub Desktop.
Save priesdelly/5f0d8582a7fa85090b40953b95deed01 to your computer and use it in GitHub Desktop.
Example static variable
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