I have this code about a periodic table and I have a csv file that I need to read, the program already does it, however, when I want to print a row with an iterator with the data, it prints a column, how do I print the rows?
Inside the while loop instead of
println( str ); use
print( str + " " ); Of course you'll need a separate call to println() with no parameters after the while loop to end the line.
Carey Brown wrote:Inside the while loop instead of
println( str ); use
print( str + " " ); Of course you'll need a separate call to println() with no parameters after the while loop to end the line.
Thanks, and do you know if there is a way to print a row instead of a column?
Carey Brown wrote:Inside the while loop instead of
println( str ); use
print( str + " " ); Of course you'll need a separate call to println() with no parameters after the while loop to end the line.
Thanks, and do you know if there is a way to print a row instead of a column?
I don't understand, that's the question I answered above.
This is an example of how a couple of helper methods can make the intent of your code clearer. This also uses try-with-resources to automatically close the reader when it's done.
Carey Brown wrote:This is an example of how a couple of helper methods can make the intent of your code clearer. This also uses try-with-resources to automatically close the reader when it's done.
Nit pick: Variable and method names should begin with a lower case letter.
Are you sure you want to catch the exception? Often we catch the exception out of habit when we should really be letting the exception bubble up to be caught at a higher level. (just a thought). You can still have the "try" without the "catch" if you are doing "try-with-resources".