Reputation: 47
simple question: this will look like after the run:
text:
2
4
2 text
but i want this:
text: 2 - 4
2 text
System.out.println("text:");
for (int i = 0; i < tomb.length; i++) {
if (tomb[i] % 2 == 0) {
System.out.println("" + tomb[i]);
db++;
}
}
System.out.println(db + " text");
Upvotes: 0
Views: 54
Reputation: 407
use System.out.print()
everywhere in your code, not System.out.println();
wich is meant to print on a different line each time
Upvotes: 4
Reputation: 37584
Change this
System.out.println("" + tomb[i]);
to
System.out.print("" + tomb[i]);
Edit: Actually you also have to change this
System.out.println("text:");
to
System.out.print("text:");
Because the printer sets the cursor on the next new line.
Upvotes: 2