Full width home advertisement

Post Page Advertisement [Top]

Firstly read out few basic rules for java:
  • A class name should be started with a capital letter. Example: HelloWorld.
  • A variable started with small letter. If variable is create by joining two word example : fuel and available then it should be written as fuelAvailable. Same case with function also.
  • Function must have a written type like: void or int or String.... Example: int getFuel(){}, void destroy(){}.
  • In Java, there is no value of new line. You can write all the codes in single line. 

Now we start a HelloWorldExample:



FileName: HelloWorld.java

class HelloWorld

{

     public static void main(String args[])

     {
           System.out.println("Hello World..");
     }

}


Description:

public means this function can be accessible from other class too.

static means without making any object of class, it called.

void means it dont return any value. 


main is the function name.


String is a type, which make the variable string type. Means it store string type value like: "hello this"


args[] is an array variable name of String type.


System.out.println  is a class and function which prints the value given inside() brackets in the console.

  Prev: Java Basic Concept  -  Next: Java Object, Class and Instance

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib