SlideShare a Scribd company logo
1 of 23
Java Hello World Program
By JavaWithUs ( www.javawithus.com )
The Program
First, let us look at the complete program :
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
The output will be :
Hello World
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
public is an access specifier which states that
the class is accessible from any other class
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
class defines a class or in simpler words – a
program
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
HelloWorld is the name of the class ( or
program ). You can give any other name
BUT…
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
… that name should follow the rules of identifiers :
1. It should begin with a letter
2. Lowercase letters, upper case letters and
numbers can be used. Only $ and _ special
characters are allowed.
3. Keywords ( certain reserved words ) cannot be
used as identifiers.
4. Spaces are not allowed.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
The opening and closing braces specify the
starting and ending of the class.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
Within the class, we have a method.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
The method has a header or method
declaration ….
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
… and a body
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
The word public in the method header is the
same as the keyword public used for the
class. Here, it indicates that other classes
can call this method.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
static specifies that we can invoke this
method without creating an object of the
class.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
void indicates that the method does not
return any value.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
main is the name of the method. For a
program to be run, the name of the method
should always be main.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
With the parentheses are the arguments.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
It takes a String array as an arguments and
stores it in the variable args.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
A String is a group of letters. An array is a
group of Strings.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
The parameters to main method are passed
through command line.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
This line prints the message to the screen.
Anything within the quotes is displayed on
the screen.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Hello World” );
}
}
System is a predefined class. out is a
member of that class and println is a
method.
public class HelloWorld {
public static void main ( String[] args ) {
System.out.println ( “Welcome to JavaWithUs.com” );
}
}
The above modified program prints
Welcome to JavaWithUs.com
To understand the HelloWorld program in a
better way, read the following article :
http://www.javawithus.com/tutorial/the-
hello-world-program
Learn Java through the tutorials on our
website.
http://www.javawithus.com/tutorial/
Presentation by
www.javawithus.com

More Related Content

What's hot

What's hot (20)

Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Java interface
Java interfaceJava interface
Java interface
 
Java String
Java String Java String
Java String
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
 
React hooks
React hooksReact hooks
React hooks
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
JavaScript Conditional Statements
JavaScript Conditional StatementsJavaScript Conditional Statements
JavaScript Conditional Statements
 
Java - Generic programming
Java - Generic programmingJava - Generic programming
Java - Generic programming
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
JDBC
JDBCJDBC
JDBC
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 

Similar to Java Hello World Program

[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1Young-Ho Cho
 
Common errors v2
Common errors v2Common errors v2
Common errors v2ASU Online
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agentsRafael Winterhalter
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Palak Sanghani
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab FileKandarp Tiwari
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークTsuyoshi Yamamoto
 
Inheritance Slides
Inheritance SlidesInheritance Slides
Inheritance SlidesAhsan Raja
 
Java Generics
Java GenericsJava Generics
Java Genericsjeslie
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、GaelykでハンズオンTsuyoshi Yamamoto
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Ayes Chinmay
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 

Similar to Java Hello World Program (20)

Common errors
Common errorsCommon errors
Common errors
 
java input & output statements
 java input & output statements java input & output statements
java input & output statements
 
[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1
 
Common errors v2
Common errors v2Common errors v2
Common errors v2
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab File
 
Inheritance
InheritanceInheritance
Inheritance
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトーク
 
Inheritance Slides
Inheritance SlidesInheritance Slides
Inheritance Slides
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
Java Generics
Java GenericsJava Generics
Java Generics
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
 
Manual tecnic sergi_subirats
Manual tecnic sergi_subiratsManual tecnic sergi_subirats
Manual tecnic sergi_subirats
 
OOPs & Inheritance Notes
OOPs & Inheritance NotesOOPs & Inheritance Notes
OOPs & Inheritance Notes
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 

Recently uploaded

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 

Recently uploaded (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Java Hello World Program

  • 1. Java Hello World Program By JavaWithUs ( www.javawithus.com )
  • 2. The Program First, let us look at the complete program : public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } The output will be : Hello World
  • 3. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } public is an access specifier which states that the class is accessible from any other class
  • 4. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } class defines a class or in simpler words – a program
  • 5. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } HelloWorld is the name of the class ( or program ). You can give any other name BUT…
  • 6. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } … that name should follow the rules of identifiers : 1. It should begin with a letter 2. Lowercase letters, upper case letters and numbers can be used. Only $ and _ special characters are allowed. 3. Keywords ( certain reserved words ) cannot be used as identifiers. 4. Spaces are not allowed.
  • 7. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } The opening and closing braces specify the starting and ending of the class.
  • 8. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } Within the class, we have a method.
  • 9. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } The method has a header or method declaration ….
  • 10. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } … and a body
  • 11. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } The word public in the method header is the same as the keyword public used for the class. Here, it indicates that other classes can call this method.
  • 12. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } static specifies that we can invoke this method without creating an object of the class.
  • 13. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } void indicates that the method does not return any value.
  • 14. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } main is the name of the method. For a program to be run, the name of the method should always be main.
  • 15. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } With the parentheses are the arguments.
  • 16. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } It takes a String array as an arguments and stores it in the variable args.
  • 17. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } A String is a group of letters. An array is a group of Strings.
  • 18. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } The parameters to main method are passed through command line.
  • 19. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } This line prints the message to the screen. Anything within the quotes is displayed on the screen.
  • 20. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Hello World” ); } } System is a predefined class. out is a member of that class and println is a method.
  • 21. public class HelloWorld { public static void main ( String[] args ) { System.out.println ( “Welcome to JavaWithUs.com” ); } } The above modified program prints Welcome to JavaWithUs.com
  • 22. To understand the HelloWorld program in a better way, read the following article : http://www.javawithus.com/tutorial/the- hello-world-program Learn Java through the tutorials on our website. http://www.javawithus.com/tutorial/