I am making a program for my Java class it is supposed to give suggestions for jumbles and my Professor wants me to do it this way but for some reason tester1 and tester2 are reading null right off the bat in the first two while loops. Please help!:
package mysort; import java.util.Arrays; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Sorting { public static void main (String [] args) throws IOException { int i=0; int n=0; int t=0; int r=0; int p=0; int y=0; int q=0; BufferedReader ldj = null; BufferedReader ldc = null; ldj = new BufferedReader(new FileReader("small_j.txt")); ldc = new BufferedReader(new FileReader("small_d.txt")); String tester1; String tester2; tester1 = "1"; tester2 = "1"; int jl=0; int dl=0; while ((tester1=ldj.readLine()) !=null); { jl++; } while ((tester2=ldc.readLine()) !=null); { dl++; } ldj.close(); ldc.close(); BufferedReader brj = null; BufferedReader brd = null; brj = new BufferedReader(new FileReader("small_j.txt")); brd = new BufferedReader(new FileReader("small_d.txt")); String [] jumbles = new String [jl]; String [] dictionary = new String [dl]; for (t=0;t<jl;t++) { jumbles [t] =brj.readLine(); } for (y=0;y<dl;y++) { dictionary [y] = brd.readLine(); } String dictionary_copy[]=Arrays.copyOf(dictionary,dl); String [] jumble_copy = Arrays.copyOf(jumbles, jl); for(n=0;n<dl;n++) { dictionary_copy[n]=sortElement(dictionary_copy[n]); } for(p=0;p<jl;p++) { jumbles[p] = sortElement(jumbles[p]); } for(q=0;q<jl;q++) { r = 0; System.out.println(jumble_copy[q]+" possible matches:"); for(r=0;r<dl;r++) { if(jumbles[q]==dictionary_copy[r]) { System.out.println(dictionary[r]); } } } } public static String sortElement(String d) { int b=0; int n=d.length(); char [] l = d.toCharArray(); Arrays.sort(l); d=""; for (b=0;b<n;b++) { d=d+l[b]; } return d; } }