string array loop print value null java -
i have instantiated string array containing 10 strings. want ask user enter subject name until 10 strings finished, or if user enters "q" quit. once happens, string array elements should printed via printarray method. have far, "null" value displayed each value after "the array elements:" make total of 10 strings. happens if enter "q" after few entries , not ten. i'd rid of "null" values , if user doesn't enter "q", after 10th entry, should display 10 arrays. { // instantiate string array can contain 10 items. string[] array = new string[10]; // read names of subjects array // , count how many have been read in. // there may fewer 10. scanner input = new scanner(system.in); system.out.println("please enter subject name or enter q quit: "); string subject = input.nextline(); int i=0; while (!"q".equals(subject)) { array[i]=subject; i...