Error while printing out arrays
Code:
public static void printWords(Scanner outFile, Word[] list)
throws FileNotFoundException{
int i = 0;
System.out.println("printing words");
PrintStream output = new PrintStream(new File("outfile"));
output.println("words in \nsorted order \t number of \n occurences");
output.println("----------------------------------");
while (i < list.length && list[i] != null) {
output.println(list[i] + "\t" + list[i].getCount() + "\n"); //Right here is the trouble
i++;
}
}
Basically when I'm trying to print out the array I get the [@edf56s or whatever numbers and not the actually word in the array. Yes I have tried Arrays.toString method. I've done Arrays.toString(list[i]) but I get a WordProcessing.java:133: error: no suitable method found for toString(Word). I have tried Arrays.toString(list) and it not only didn't print out the words but it print out the [@ef56s codes instead.
Re: Error while printing out arrays