Let’s start the programming by compiling and running following
small program.
class one
{
public static void main(String args[])
{
System.out.println(“Welcome to the World
of JAVA!!!”);
}
}
If you are using JDK, follow the following steps:-
1) Type above
program in notepad / notepad++.
2) Save this
program as one.java in bin folder of
jdk folder.
3) Open command prompt.
4) Type cd
source of bin folder.
5) Type javac one.java
By this step, JAVA compile that program and create one.class file in same folder where the
one.java file is saved.
6) Again type java one
Above means running that .class
file
You will get the output.
If you are using ECLIPSE,
follow the steps below:-
1) Type above
program in ECLIPSE.
2) Save that
program.
3) Then click
on run button or press F11.
4) The output
will display below the program window
Description
of above Program:-
class one {
statements } :-
This is the start of the program.
Keyword class represents the
beginning of the class. Word after class
keyword represents the name of class.
Syntax:-
class
class_name
public
static void main(String args[]) :-
From this line main() method is begin. In JAVA all application execution begins by
calling main() method.
The public keyword is an access specifier, which
allow programmer to control the visibility of class member.
Static
The void keyword tells the compiler that
main() method does not return any value.
The String args[] is passes as parameter to
the main() method. It represents the Array of arguments of type
String.
System.out.println();
:-
This
statement simply prints the output on the screen. Every statement in JAVA ends
with semicolon (;) except methods.
// :-
These lines use to add comment. Whatever written after this line is
hidden from the compiler hence those lines doesn’t execute while compiling and
running the code
/*…..*/ :-
This block
is also used to add comment.
0 comments:
Post a Comment