I use System.out.printf method to format the string and print a line but
after that i need to print another line through for loop with print method without moving new line.
Now after used printf method it will move to new line. but i don’t need to move new line until print my for loop.
is it possible??
or can u tell any other way
here is my sample code
System.out.printf("%7s %s%n",names[i], " ");
for (int j = 0; j < 5; j++) {
System.out.print( grades[i][j] + " " );
}
System.out.println();
printfdoesn’t by default print a new line. You really should read the documentation. When you explicitly print a new line using the%nnewline placeholder, you shouldn’t be surprised you get a newline …So just remove the
%nif you don’t want it.