Detailed Print – Computer Sir Ki Class


Lost your password?

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

Code Learning#JAVA#551

Hello World 2

This is a program that prints hello world! given as two separate words.

Learning Objectives

To learn java concepts related to :

  • adding two parts of a string while printing.

Program Approach

The objective is just to demonstrate the use of + for displaying two strings Since we want the two words hello and world to be displayed adjacently we will use two separate string literals concatenated (added) with +sign.

Source Code


Click to open popup

Run Output

Hello World!

Code Understanding

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

In this statement we have put the two words to be displayed as two separate string literals within” ” (double quotes). We will then join these string literals using a + operator in between. The compiler would automatically assume + as a string joiner and not as arithmetic + , what it is usually meant for.

Suggested Filename(s):