Array vs Arraylist differences
One option how to create array and specify values :
int[] myIntArray = new int[]{1,2,3}; // Initialization and values
Second 2 options will give you error "Array constants can only be used in initializers". So please dont use them.
private int[] myNumbers;
int[] myIntArray = new int[3];
- Array has fixed size Vs Arraylist has flexible size
One option how to create array and specify values :
int[] myIntArray = new int[]{1,2,3}; // Initialization and values
String[] myStringArray = new String[]{"a","b","c"}
Second 2 options will give you error "Array constants can only be used in initializers". So please dont use them.
private int[] myNumbers;
myNumbers= new int[3]; //Initialization
myNumbers={1,2,3};
int[] myIntArray = new int[3];
int[] myIntArray = {1,2,3};
ArrayList
ArrayList<Class> myList = new ArrayList<Class>();
Комментариев нет:
Отправить комментарий