java user-defined array (and user-defined array size) returning [null, null, null, ...] -


this first question on site, i'm running on netbeans 8.0.2 , trying print out user-defined array keeps returning null values. example if there 2 employees , enter both of names, return [null, null]

how fix error? i'm novice.

import java.util.scanner; import java.text.decimalformat; import java.util.arrays;  class tips_calculation2  { public static void main(string[] args) {     scanner scan = new scanner(system.in);      system.out.print("how many employees week?: ");     int numberofemps = scan.nextint();      // counter if statement should return employees array     int counter = numberofemps;      int[] noearray = new int[numberofemps];       system.out.println("\nenter names of workers entered amount (" + numberofemps + "):");       for(int = 1; <= numberofemps; i++)     {         string namecycler = scan.next();         string[] namesarray = new string[i];          if(counter == i)         {             system.out.println(arrays.tostring(namesarray));         }     } } } 

disregard import java.text.decimalformat plan use import later on in code. thank in advance kind/smart enough respond.

first of never put namecycler array. second of create namesarray every iteration think wrong.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -