Your SlideShare is downloading. ×
Java Hello World Program
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Java Hello World Program

11,068
views

Published on

This presentation explains the 'Hello World' program in Java.

This presentation explains the 'Hello World' program in Java.

Published in: Education, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
11,068
On Slideshare
0
From Embeds
0
Number of Embeds
36
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Java Hello World ProgramBy JavaWithUs ( www.javawithus.com )
  • 2. The ProgramFirst, 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 thatthe 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 – aprogram
  • 5. public class HelloWorld {public static void main ( String[] args ) {System.out.println ( “Hello World” );}}HelloWorld is the name of the class ( orprogram ). You can give any other nameBUT…
  • 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 letter2. Lowercase letters, upper case letters andnumbers can be used. Only $ and _ specialcharacters are allowed.3. Keywords ( certain reserved words ) cannot beused 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 thestarting 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 methoddeclaration ….
  • 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 thesame as the keyword public used for theclass. Here, it indicates that other classescan call this method.
  • 12. public class HelloWorld {public static void main ( String[] args ) {System.out.println ( “Hello World” );}}static specifies that we can invoke thismethod without creating an object of theclass.
  • 13. public class HelloWorld {public static void main ( String[] args ) {System.out.println ( “Hello World” );}}void indicates that the method does notreturn 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 aprogram to be run, the name of the methodshould 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 andstores 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 agroup of Strings.
  • 18. public class HelloWorld {public static void main ( String[] args ) {System.out.println ( “Hello World” );}}The parameters to main method are passedthrough 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 onthe screen.
  • 20. public class HelloWorld {public static void main ( String[] args ) {System.out.println ( “Hello World” );}}System is a predefined class. out is amember of that class and println is amethod.
  • 21. public class HelloWorld {public static void main ( String[] args ) {System.out.println ( “Welcome to JavaWithUs.com” );}}The above modified program printsWelcome to JavaWithUs.com
  • 22. To understand the HelloWorld program in abetter way, read the following article :http://www.javawithus.com/tutorial/the-hello-world-programLearn Java through the tutorials on ourwebsite.http://www.javawithus.com/tutorial/
  • 23. Presentation bywww.javawithus.com