Yeah, you are correct. I thought it would automatically would be done with split(" ") or split("\\s"), but I need to use split("\\s+"). Then the code works.
Thank you veru much for your time! :)
Type: Posts; User: jjk
Yeah, you are correct. I thought it would automatically would be done with split(" ") or split("\\s"), but I need to use split("\\s+"). Then the code works.
Thank you veru much for your time! :)
Ok, sorry I misunderstood what you wanted. I changed the code so that in each pass in the while loop it also prints out each of the content in the line array:
import java.util.*;
import...
I added this code in the while loop: System.out.println(Arrays.toString(line));
And the output became:
[Tom, , , , , , , , 44]
[Arnold, , , , , 98]
[Susie, , , , , , 24]
[Johnny, , , , ,...
[Tom, , , , , , , , 44]
[Arnold, , , , , 98]
[Susie, , , , , , 24]
[Johnny, , , , , 17]
Thanks I used your last codebit, and this is what i got. The problem is in the split it seems. What I...
Hello, I am practicing reading from a text-file into arrays. I have encountered a problem I am not able to solve.
I have a file called "nameage.txt":
Tom 44
Arnold 98
Susie 24...
Thanks guys, it makes very much sense now.
Since I have your attention I would like to ask you some general questions about this topic aswell, I hope you can spare the time.
I have only...
Hello, I am very basic to Java. I was programming when something strange occured, I have isolated the problem so that you need to read as little as possible.
First a short code, where there is...