Software Testing Material

A site for software testers. We provide free online tutorials on Manual Testing, Automation Testing - Selenium, QTP, LoadRunner, Testing Tools and many more.

  • Blog
  • Tutorials
    • Manual Testing
    • Java
    • Selenium
      • TestNG
      • Maven
      • Jenkins
    • Framework
    • Katalon
    • Agile
    • SQL
    • VBScript
    • API Testing
  • Tools
    • TestLodge
    • FrogLogic GUI Tool
    • CrossBrowserTesting
    • BrowserStack
    • TestCaseLab
    • Kobiton
    • PractiTest
    • Sikuli
    • Postman
  • Interview Q & A
    • Selenium
    • TestNG
    • Test Framework
    • Explain Framework
    • Manual Testing
    • Software QA
    • Agile
    • Testing As A Career
    • General Interview Questions
    • API Testing
    • SOAP
    • JIRA
    • Protractor
  • Free Resources
  • Guest Post
    • Guest Post Guidelines
  • Training

Print In Java | Java Tutorial

Last Updated on January 12, 2019 by Rajkumar

We use print in java to output required text directly to the console of IDE. Let’s see the syntax of print in java and the difference between print and println in Java.

Syntax of Print in Java:

Simple print statement:

1
System.out.print(“Learning Java from SoftwareTestingMaterial”);

A simple print statement with a new line:

1
System.out.println(“Learning Java from SoftwareTestingMaterial”);

What is the difference between print and println methods in Java?

The basic difference between the print() and println() methods in Java are when using println(), the cursor in the output will be shown in the next line after printing the required output on the screen whereas when using print() method, the cursor will be shown in the same line after printing the required output on the screen.

Sample Program:

Simple print program – Print text and stay in the same line

1
2
3
4
5
6
7
8
9
10
11
12
package classOneGeneral;
 
public class Print {
// Simple print program - Print text and go to new line
public static void main(String [] args){
System.out.print("Learning Java from SoftwareTestingMaterial");
System.out.print("Learning Java from SoftwareTestingMaterial");
}
 
}

Simple print program – Print text and go to a new line

1
2
3
4
5
6
7
8
9
10
11
12
package classOneGeneral;
 
public class Print {
// Simple print program - Print text and go to new line
public static void main(String [] args){
// println adds a new line
System.out.println("Learning Java from SoftwareTestingMaterial");
System.out.println("Learning Java from SoftwareTestingMaterial");
}
}

Declaring a variable named website and print some text and go to a new line

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package classOneGeneral;
 
public class Print {
 
// Declaring a variable named website and print some text and go to new line
static String website = "SoftwareTestingMaterial";
public static void main(String [] args){
// Print text and go to new line
System.out.println("Learning Java from "+website);
// In above statement we used "+" to concatenate website with the given text
}
}

Must Read: Java Tutorial

SUBSCRIBE TO GET FREE EBOOK AND REGULAR UPDATES ON SOFTWARE TESTING

Filed Under: Java

data-matched-content-rows-num="2" data-matched-content-columns-num="3"
Previous Article:
Do While Loop In Java
Next Article:
User Input In Java

About the Author

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

ADVERTISEMENT

Froglogic-Squish-GUI-Tester
CrossBrowserTesting

TUTORIALS

  • Manual Testing Tutorial
  • Selenium Tutorial
  • TestNG Tutorial
  • VBScript Tutorial
  • Agile Methodology
  • SQL Tutorial for Testers
  • INTERVIEW QUESTIONS

  • Framework Interview Questions
  • Real Time Manual Testing
  • 100 Top Selenium Interview Questions
  • 30 Top TestNG Interview Questions
  • Agile Interview Questions
  • 80 SQL Interview Questions
  • TESTING TOOLS

  • Test Lodge
  • FrogLogic Squish
  • Cross Browser Testing
  • BrowserStack
  • Test Case Lab
  • Sikuli
  • © 2019 www.softwaretestingmaterial.com | About us | Privacy Policy | Contact us | Guest Post | Disclaimer | Terms of use | Sitemap