Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Understanding Hello World Java Program

                         

Now you are familiar with the Java program. In the last lesson you learned how to compile and run the Java program. Before start hard programming in Java, its necessary to understand each and every part of the program. Lets understand the meaning of  public, class, main, String[] args, System.out, and so on.

 

 

 

 

 

   public class HelloWorld { 
        public static void main(String[] args) { 
                      System.out.println("Hello, World");
                         }
                   }

Class Declaration:

Class is the building block in Java, each and every methods & variable exists within the class or object. (instance of program is called object ). The public word specifies the accessibility of the class. The visibility of the class or function can be public, private, etc. The following code declares a new class "HelloWorld" with the public accessibility:

public class HelloWorld { 

The main Method: 

The main method is the entry point in the Java program and java program can't run without main method. JVM calls the main method of the class. This method is always first thing that is executed in a java program. Here is the main method:

public static void main(String[] args) {

......
.....

}

{ and is used to start the beginning of main block and } ends the main block. Every thing in the main block is executed by the JVM.

The code:

System.out.println("Hello, World");

prints the "Hello World" on the console. The above line calls the println method of System.out class.

The keyword static:

The keyword static indicates that the method is a class method, which can be called without the requirement to instantiate an object of the class. This is used by the Java interpreter to launch the program by invoking the main method of the class identified in the command to start the program.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

6 comments so far (
post your own) View All Comments Latest 10 Comments:

pliz help me write a jav program that prints 10 multiples of a certain number which are greater than a certain number

Posted by Thaane on Wednesday, 09.17.08 @ 23:20pm | #80145

how to draw two flowcharts. The first chart will describe how a program called Hello is programmed using C# or Java (your choice) from the very beginning when you write the program to the beautiful end when the program is stored to hard disk to folder c:\programs\hello in the executable form (named hello.exe). Describe the phases from C# -program to executable.

Posted by Eric kwasi on Thursday, 05.8.08 @ 21:28pm | #58944

Firstly, I haven't understand ur tutorial and secondly, what is it's use

Posted by Ravi on Thursday, 10.4.07 @ 23:36pm | #31413

class A{
-----
}
class B extends A{
---------
---
}
public static void main( string args[])
{
-------
}is this excuted with out creating object?

Posted by suman on Friday, 05.4.07 @ 11:48am | #15254

After succesful compilation when i give the command java HelloWorld
i got the error as
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

what is the reason

Posted by srinadh on Sunday, 03.11.07 @ 16:47pm | #11368

sir please tell me why we use static variable.

Posted by hardesh kumar on Thursday, 02.1.07 @ 12:40pm | #5164

Latest Searches:
java.util.Calendar
spring:html tags examp
jsp:forward tag
Lookup Dispatch Action
struts2 radio button
add picture to a swing
drow arc
program in java to ins
set value to httpsessi
Aะ??ะ?ย�??ะ?
sequence number
qMgr.accessQueue(
calling one jsp p
servlet hello world co
Icon
Hospital UML diagrams
reflection api
struts-blank.war
Photoshop Color Painti
how to use unique cons
17
strut
TextArea Frame in Java
session validation in
Javadoc
HTML .htaccess Rewriti
chicken
Print
trim().length()
Diff bet MVC Model1 an
pl/sql
jdbc connection source
displaying text in a d
read integers from fil
Convert a String into
sorting with dropdown
ย  in struts
Photoshop Screen Effec
Convert Integer to Flo
ASP Excel and ASP Extr
get url
How to deploy a java p
java strings
how to use email valid
Expression Language
jdbc html jsp
showMessage
value change listener
jboss portal
icon a JButton
pb tree implementati
covert uppercase to lo
Eclipse 3.4 EJB
struts e file jpeg
how to capture multipl
Get Array List in a JS
create table using jsp
microsoft word
try example
spring applicationcont
jsp drop down menu
jasper report
Copy one or more files
how to write hql in da
ArrayList
jstl
wap to print a trriang
PHP Database Related O
login jsp
Photoshop Drawing Drag
passing array
delete data to text fi
rational rose
how to capture multipl
how to declare an arra
JSF panelGrid render
add in excel
assertNull
Java Count Vowels
Applet JSP Programing
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.