Hello World 1 – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Code Learning #JAVA#535 siteicon   siteicon   siteicon  

Hello World 1

This is a program to learn console output with and without newline.

Learning Objectives

To learn java concepts related to :

  • Difference between print() and println() method for showing the output to console.

Program Approach

The objective is to demonstrate console output using multiple print or println methods.

Since we want that the second output should come adjacent to the first one we will use theprint() method in the first statement but in the second statement we will use println() as we want the other outputs to be displayed in the next line.

Source Code

TC++ #535

Source Code

Run Output

Hello World!

Code Understanding

System.out.print(“Hello “);

In this statement we have not used println() method, instead we have used print() as we want the next output to be displayed in the same line.

System.out.println(“World!”);

In this statement we have used the method println() as we want the other outputs to be displayed in the next line.


Suggested Filename(s): HelloWorld1.java



Share

admin| Created: 13-Aug-2016 | Updated: 8-Dec-2017|









Back