You are on page 1of 4

Learn Java programming structure

Here in this article, it has been explained about the Java Hello World scenario
with structures and features of class and this code is written to fullfill the task
of printing Hello World from Java on the screen.
1. package sct:
It is a statement for package declaration. This definition of package statement
shows a name space in which classes is stored. Package is used to arrange the
sessions based on performance. If you bypass the package statementt, the
course titles are put into the standard system, which has no name. Package
statement cannot appear anywhere in system. It must be the first linee of your
system or you can bypass it.
2. public class HelloWorld:
This linee has various elements of Java development.
a. public: This is accessibility modifier keyword and key phrase which informs
compiler accessibility to category. Various principles of accessibility modifiers
can be community, secured,private or standard (no value).
b. class: This keyword and key term used to announce category. Name of class
(HelloWorld) followed by this keyword and key term.
3. Feedback section:
We can create comments in Java in two ways.
a. Line comments: It begins with two forward slashes (//) and proceed to the
end of the presentline. Line comments do not have an finishing icon.
b. Block comments start with a forward slasj and an asterisk (/*) and end with
an asterisk and a forward slash (*/).Block comments can also increase across
as many lines as required.
4. public fixed gap primary (String [ ] args):

Its technique (Function) known as core with sequence range as discussion.


a. public : Access Modifier
b. static: It is arranged keyword which means that a technique is offered and
useful even though no things of the course are available.
c. void: This keyword and key word states nothing would be a come back from
technique. Method can come back any basic or item.
d. Method material within wavy tooth braces. { } asdfla;sd
5. Program.out.println(Hello Globe from Java) :
a. System:It is name of Java application class.
b. out:It is an object which is associated with Program class.
c. println:It is an application technique name which is used to deliver any String
to system.
d. Hello Globe from Java:It is String actual set as discussion to println method.
More Info on Java Class:
Java is an object-oriented language, which indicates that it has constructs to
signify factors from the actual life. Each Java system has at least one class that
knows how to do certain factors or how to signify some kind of item. For
example, the easiest class, HelloWorld,knows how to welcome the globe.
Sessions in Java may have techniques (or functions) and areas (or features or
properties).
Lets take example of Car item which has various qualities like shade, max rate
etc. along with it has features like run and quit. In Java globe we will signify it
like below:
package sct;
public class Car {

private String color;


private int maxSpeed;
public String carInfo(){
return color + Max Speed:- + maxSpeed;
}
//This is constructor of Car Class
Car(String carColor, int speedLimit){
this.color = carColor;
this.maxSpeed =speedLimit;
}
}
Lets create a class known as CarTestwhich will instantiate the car class object
and contact carInfo way of it and see outcome.
package sct;
//This is car test class to instantiate and call Car objects.
public class CarTest {
public static void main(String[] args) {
Car maruti = new Car(Red, 160);
Car ferrari = new Car (Yellow, 400);
System.out.println(maruti.carInfo());
System.out.println(ferrari.carInfo());

}
}
Output of above CarTest java class is as below. We can run CarTest java
system because it has primary technique. Main technique is place to begin for
any java system performance. Operating software indicates informing the Java
VIrtual Device (JVM) to Load theclass, then begin performing its primary ()
technique. Keep running til all thecode in primary is completed.

You might also like