|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Unable to output number to just one line.
I'm just starting a JAVA class. One of the assignments on the homework is as follows ...
The output result should be: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 (displayed on only one line) Here is my attempt at it: __________________________________________________ _ public class NumberOutput { public static void main(String[] args) { int i=1, end=19; //declarations and assignments while (i<end) { System.out.println(i + ", "); i+=2; }//end of while loop System.out.println(end); } //end of main() method } //end of NumberOutput class __________________________________________________ _ When I run this, I get the numbers, but just not on one line ... Any suggestions as to how to proceed would be appreciated. Thanks for your time. Navjot |
|
#2
|
||||
|
||||
|
Try using print() instead of println()
|
|
#3
|
|||
|
|||
|
Thanks for the help. That was the correct command.
I'm still waiting for the book to come in, and the print() command would probably have been in there. Have a good one. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Unable to output number to just one line. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|