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
Run Output
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): HelloWorld2.java
admin| Created: 16-Aug-2016 | Updated: 13-Dec-2017|