Hello,
I have a problem with setting the size for a dynamic array, it's best to give an example:
Question: how to set the size of the String name [] in the main method? I would like the user, while the program is running, to choose how many names (eg) can be assigned to a person (the size of the dynamic array Name []).
ps: I'm a beginner, so please be understanding;]
I have a problem with setting the size for a dynamic array, it's best to give an example:
public class Osoba {
String imie[]; //dynamiczna tablica
}
public class Przyklad{
public static void main(String[] args){
int rozmiar=5;
Osoba nowy[] = new Osoba();//dynamiczna tablica obiektow
}
}
Question: how to set the size of the String name [] in the main method? I would like the user, while the program is running, to choose how many names (eg) can be assigned to a person (the size of the dynamic array Name []).
ps: I'm a beginner, so please be understanding;]