Monday, January 5, 2015

Java program to print multiline


The java program given below will print multiline after running. This is a very simple java program like the HelloWorld program. In HelloWorld program we printed a single meassage Hello World! using the line System.out.println("Hello World!"); and in this program we have to use the same line for five times.

But we may do the same thing by the second program. In the second program, I have used the print command once but five several messages with /n.
java programming,object oriented programming,multiline in java
The first program to print multiline...
public class MultiLine
{
public static void main(String [] args)
{
System.out.println("1. This is the first line");
System.out.println("2. This is the second line");
System.out.println("3. This is the third line");
System.out.println("4. This is the fourth line");
System.out.println("5. This is the fifth line");
}
}

The second program to print multiline...
public class MultiLine
{
public static void main(String [] args)
{
System.out.println("1. First line\n2. Second line\n3. Third line\n4. Fourth line\n5. Fifth line");
}
}


No comments:

Post a Comment