Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Parameters used in the Program

  • class - class keyword is used to declare a class in java.
  • public - public keyword is an access modifier. It is the most non-restricted type modifier. It means it is visible to all.
  • static - static is a keyword. If we declare any method as static, it is called a static method. The advantage of the static method is that we don't have to create an object to access it. The main method is executed by the JVM, so it doesn't require to create an object to invoke the main method.
  • void - the void is a return type of a method. It means that it does not return any value.
  • main - It represents the starting point of the program.
  • String[] args - In java args contains the supplied command-line arguments as an array of string.
  • int - It is used to store the integer value.
  • System.out.println() - It is used to print the statement. The system is a class, out is the object of PrintStream class, println() is the method of PrintStream class which displays the result and then throws the cursor to the next line.

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

The only difference between println() and print() method is that println() throws the cursor to the next line after printing the desired result whereas print() method keeps the cursor on the same line. 

Example -

print() method.

System.out.print("Tutorial ");
System.out.print("Links");

The output for these statements will be-

Tutorial Links

println() method.

System.out.println("Tutorial ");
System.out.println("Links");

The output for these statements will be-

Tutorials

Link

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now