Difference between System.out.print() and System.out.println()

0
01.Java Basics.

What is the difference between System.out.print()  andSystem.out.println()?
"ln" is the difference
It means
println() method places the cursor in the next line after printing current output. So that the next coming output will be printed in next line.
But whereas print() method places the cursor in the same line after printing current output. So that the next coming output will be printed in same line.

 //  Println.java
class Println
{
public static void main()
  {
    System.out.println("A");
    System.out.println("B");
  }
}

OutPut:
A
B



//Print.java
class Print
{
  public static void main()
  {
    System.out.print("A");
    System.out.print("B");
  }
}

OutPut:
AB

//PrintAndPrintlnDemo.java
class PrintAndPrintlnDemo
{
  public static void main(String[] args)
    {
    System.out.print("Welcome to the WWW.NetLoJava.blogspot.Com ");
    System.out.println("And Welcome to JAVA PrintAndPrintlnDemo");
    System.out.print("Work Smart");
    System.out.println("And Get Best Results");
    System.out.println("All the best for your Java Career");
  }
}
OutPut:
Welcome to the WWW.NetLoJava.blogspot.Com And Welcome to JAVA PrintAndPrintlnDemo
Work SmartAnd Get Best Results
All the best for your Java Career




Previous  1  2  3  4  5  Next

About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts