The mistake is probably obvious, but we just started arrays.
With that, all you'd have to read the file as a string then convert it.
To print an array you need to put it into a loop.
Also, I would change the way that the file is being read in.
Yours starts at answers rather than answers.
I think it would be easier to put it into a while loop when reading a file
Greg Charles wrote:Just to be clear, your text file has multiple lines, and you want to return the first letter of each line in a char array? Or you want to return all characters in the file in a char array. It's hard to say without knowing your goal, but I'd guess your main mistake is using hasNext() the way you are.
Actually, I'm wanting to grab every other line in the file, each of which contains letters, and return an array containing all of the letters in the line.