Monday 14 December 2015

what is public? what is static? what is void? what is main? what is string args[]? what is system.out.println()? in java

                                                           Hiiiiii... am back to tell what is?

ok see the code once again (not the C O D E ):

C O D E:
          package com;
          public class HelloJavaClassName

          {
          public static void main(String []args)

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


what is public?

public class HelloJavaClassName

we called this (Public, Private, Protectedaccess modifiers ...and also this is a keyword so we can not use this as variable. I hope you know what is  variables if you are not I do not care ha ha ha...

Public is like Public, a variable or method is public means that can access by any class

Ex:--
                  public int a;

 this is a public variable this variable can access from anywhere form your entire application so we called this as global variable

oK dude! what is 

public class HelloJavaClassName
{

}

This is called class , it can be defined as template it describes the object behaviours
 

ok then what is object ?


Object is an instance of a class it  has its own states and behaviours.

ok yaaarrr now I can understand what is class but inside the class something is there what is that?

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

}

This is what we called method,  a class can contain many method  u can c d keyword  main so this is main method. It is always public because it has to be accessed by the runtime.

yaa u can create your own method inside the class ... but listen you method name should start with smaller case (naming conversion).

for example:

public class HelloJavaClassName
{
public void shouldStartWithSmallCase()
}

this is called method name shouldStartWithSmallCase()

What is static?


Static is also keyword, if You use static keyword to the variable that variable value is static to the entire application.

public class HelloJavaClassName
{
static int pi=3.14159265358979323846264338327950288419716939937510582097494459230781640
}

The pi value is, Oh! sorry you can use 3.14 this value never going to change so we can declare this pi variable as static, for your entire program the pi value is 3.14 only this is we called static variable

static variable gets memory once at the time of class loading...


oKeY! why we use public static void main(String []args) ?

This is the main function, any doubt on that if any read from first. Main function should run first , the static keyword trigger the main function for first execution. so every program started to run from main class. That means main class always run first.

what is void ?

This method just print helloworld so we are not going to return any value here, void means that the method has no return value.

what is string args[]?

string and args is keyword ,java takes every values as string so we use the data type string.args[] is argument array of console line values stored in the [] array argument.
I know it is little bit difficult to understand study about array and data type then u can understand little bit more...

what is system.out.println()?

what is class? what is package(check on previous post)? what is method?
 
If you know the answer for the previous questions then you can understand system.out.println
 
System  is a class in the package of  java.lang
 
out  is the instance of java.io.PrintStream
 
println is the methosd of  java.io.PrintStream
 
This will help to print the output......
 
ok session is end today c u sooon...












  

Thursday 10 December 2015

Java hello world in eclipse

Here, i am going to  discuss about very basic java learning blah blah blah...k lets start the hello wold program in java using eclipse.



Java hello world in eclipse
This is the first step :

Open your eclipse click file -> New -> and select Project


Java hello world in eclipse

Step 2:

select the java project...

Java hello world in eclipse

step 3:

now u can see the window ... just give the project name and click finish


Java create class

step 4:

click your project  name ..Oooops right click your project name and again new -> Class


Java create class and packages

Step 5:

Package: yah that is package , I can see that but what is package?

package is  similar to different folders on your computer ...( i can not explain about  folders and computers if you want to know mail me...) 
you can create packages (folders) to write your class , i gave [] com [] in the package name

Name: it's your class name ...give it and click finish


Java hello world



Step 6:

your package and class created ,now type the code... or copy paste it

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


Now press the play button or press  Ctrl + F11 you can see the result in the console window...



Yah ! you run your first java program but
what is public?
what is static?
what is void? 
what is main?
what is String args and what is []?
what is System.out.println();?

try to search on web else wait for the next post.....