Write an application that displays the numbers 1 to 4 on the same line
Hi, I'm going to be taking an object oriented paradigm using java during intersession in a few months. I'm trying to brush up on it a bit and have come across a simple little problem that have no idea how to solve.
The problem is. Write an application that displays the numbers 1 to 4 on the same line, with each pair of adjacent numbers separated by one space.
Write the program using the following techniques:
- Use one system.out.printLn statement.
- Use four system.out.print statement.
- Use one system.out.printf statement.
This is what i have so far but I'm a little lost.
Code:
public class Display
{
public static void main(String [] args)
{
System.out.print("1 ");
System.out.print("2 ");
System.out.print("3 ");
System.out.print("4 ");
System.out.println(" ");<----is that what that is supposed to look like, and where it goes?
System.out.printf(" %s %s %s %s ");????
}
}
i cant test this my console isn't working right, and i haven't finished my compiler install.
Thanks