Saturday, 24 February 2018

Java Course for Beginner Article 1.

What goes in a source file? 

A source code file (with the .java extension) holds one class definition. The class represents a piece of your program, although a very tiny application might need just a single class. The class must go within a pair of curly braces.

public class Dog {

}

class

What goes in a class?

A class has one or more methods. In the Dog class, the bark method will hold instructions for how the Dog should bark. Your methods must be declared inside a class (in other words, within the curly braces of the class).

public class Dog {

void bark () {

     }
}

Method


What Goes Into a method?

Within the curly braces of a method, write your instructions for how that method should be performed. Method code is basically a set of statements, and for now, you can think of a method kind of like a function or procedure.

public class Dog {
void bark () {
statement1;
statement2;
}
}

Statement


Anatomy of a class 

When the JVM starts running, it looks for the class you give it on the command line. Then it starts looking for a specially-Written method that looks exactly like:
public static void main (String() args  (
II your code goes here
Next, the JVM runs everything between the curly braces { }of your main method. every java application has to have at least one class. and at least one main method (not one main per class; just one main per application).



1 comment:

  1. Nice article for java beginner try upload regular post of java programing

    ReplyDelete