title: instantiating Two arrays from two text files
body: <p>I am trying to instantiate the String array cool with items from the file "cool.txt" and the same for the array warm except with the text file "warm.txt" the program works to an extent however many elements of the array are labeled as null like this <img src="https://i.stack.imgur.com/wcQyS.jpg" alt="enter image description here">  </p>
  
  <p>This is partially correct as they array has all the correct items; just millions of null's after</p>
  
  <p>here is my code </p>
  
  <pre><code> int count2=0;
     int count3=0;
     String[] filename ={"Cool.txt","Warm.txt"};
     String[] cool =new String[30];
     String[] warm =new String [3000];
     String[][] arrays = new String [][]{cool,warm};
     BufferedReader fr;
  
  
  
    try
    {
     for(int i=0; i&lt;2; i++)
     {
     fr = new BufferedReader(new FileReader(filename[i]));
    String line = fr.readLine();
  
     while (line != null)
            {
  
                  if (i&lt;=0)
                {arrays[i][count2]=line;
                System.out.println("COOL");    
                count2++;}
  
        if(i&gt;=1)
        {arrays[i][count3]=line;
        System.out.println("WARM");    
        count3++;}
  
        line = fr.readLine();
  
  }
    fr.close();
  
  
      }
  
     System.out.println(Arrays.asList(warm));
     System.out.println(Arrays.asList(cool));
    }
  
  
  
  
            catch(Exception F){
         System.out.println("NUL");
     }
  
  } 
  </code></pre>