Question: If youre up for a bit more of a challenge, try arranging the output in a visual triangle. The statement above prints one element on

If you’re up for a bit more of a challenge, try arranging the output in a visual triangle. The statement above prints one element on a line by itself. The built-in System. out object has another output method: print(). This method does not print a newline after it prints whatever argument was passed in. You can chain together several System.out.print() calls to produce one line of output:

System.out.print("Hello"); System.out.print(" "); System.out.print("triangle!"); System.out.println(); // We

Your final output should look similar to this: 

% java Triangle 0 12 2 3 4 3 4 5 6 45678

System.out.print("Hello"); System.out.print(" "); System.out.print("triangle!"); System.out.println(); // We do want to complete the line // Output: // Hello triangle!

Step by Step Solution

3.49 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To achieve the desired output of a visual triangle you can use nested loops to generate the numbers ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java An Introduction to Problem Solving and Progra Questions!