java - How to draw asterisks (*) line on the screen? -
how can draw horizontal line using around 50 asterisks *
, using loop? when tried this, result 50 asterisk listed vertically (instead of horizontally).
public void drawastline() { (int = 0; < 3; i++) system.out.println("*"); }
any suggestions?
you need use system.out.print('*')
instead of system.out.println('*')
.
system.out.println('*'); => system.out.print('*'); system.out.print('\n');
for case, output looks *\n*\n*\n*\n*\n
, \n
escape sequence inserts newline in text @ point. print('*')
allows avoiding , output *****
.
Comments
Post a Comment