Adding strings to an array

Okay so i’m trying to figure out how to add a variable string “student name” to an array.

Does an arrays size have to be pre -determined?

This is what ive done! do i need to make a new class for the array
or can i put it all in this class?:confused:

public class AddStudent {

/**
 * @param args the command line arguments
 */
public static void main(String args[])
{
Scanner newStudent = new Scanner (System.in);

System.out.println("Please enter student name:"); //prompt for input
String studentName = newStudent.nextLine(); // read line of input
System.out.println(); //displays blank line
System.out.println( studentName);//displays student name
System.out.printf("has been successfully enrolled! \

");//states string

}

}

lmao You are very welcome :smiley:

yes, array sizes need to be pre determined.
Usually I use Lists instead. (e.g. an ArrayList)

You can manipulate arrays using

System.arraycopy
and the
Arrays util class