[Code Review Help] Explanation In Java Needed - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › [Code Review Help] Explanation In Java Needed (998 Views)
| [Code Review Help] Explanation In Java Needed by paranorman(op): 1:21pm On Oct 11, 2019 |
A semi-colon delimited file exists, I just wanna output its content to the console after splitting it like this using PHP: try {The above code works as expected Java's output of this code is funny: import java.io.*; } output: (1) Your name is jacob zuma zoomzoom This java code works just fine, as expected: import java.io.* ; output: (1) First name: john; last name: doe; other names: wick The text file is (output.txt) john;doe;wick question: Why is the console output of the first java program omitting the odd rows of the text file?! NL smileys are getting in the way, so I had to space some characters oddly out. |
| Re: [Code Review Help] Explanation In Java Needed by spoilerx: 5:30pm On Oct 11, 2019 |
what is the content of the output.txt file |
| Re: [Code Review Help] Explanation In Java Needed by paranorman(op): 7:40pm On Oct 11, 2019 |
spoilerx:I typed it out in my post above, in the "in text file is" session. |
| Re: [Code Review Help] Explanation In Java Needed by leoaso(m): 12:28pm On Oct 12, 2019*. Modified: 5:08pm On Oct 16, 2019 |
This is the part causing problems.
paranorman:After calling hasNextLine you should only call nextLine once. If you call it twice, it will read a line, and then read another line, which discards the first one you read. The solution is to call nextLine once inside the loop and store it in a variable. Then use that variable instead of calling nextLine repeatedly before the loop body has repeated. |
Need Help In Java • [Code Review Help] Laravel Experts Please HELP! • Question On Regular Expressions In Java • 2 • 3 • 4
I Want Teacher For C++ • Quarantine Challenge {40 Days Challenge } • PHP Password_verify() Function Fails To Work. Help!