-
public String[] gen,temp,backup;
-
Now I need to declare them as array of unknown size. I tried
-
// Try 1
-
this.gen = new String[];
-
// Try 2
-
this.gen = new String[' '];
-
-
Nothing seems to work can anyone help me with this please.
If you don't know how many strings you are going to use don't use arrays but arraylists or other classes from collections ..
When you make this:
this.gen = new String[];
you have to tell the memory how many adresses it has to allocate for you array
for example
this.gen = new String[453234];
String[] gen; // declares an array of strings (strings = array of charachters)
gen= new String[196868]; // allocates memory for 196868 strings
gen[0] = new char{'a','b','c','d'}; // initialize first element
...