Вы находитесь на странице: 1из 47

by

ArguS academy

Class Declaration
The first line ( class First ) : declares a
class , which is an object-oriented construct.
JAVA is a true object language thus
everything must be placed inside class.
class is keyword and declares that a new
class definition follows.
First is a JAVA
identifier that specifies the name of class to
be defined.

Braces
Every class definition in JAVA begin
with opening braces { and ends
with a matching closing brace }.
(note:- class definition in C++ ends
with a semicolon)

The main line


Public static void main (String args[])
Every java application program must include
the main() method . Conceptually this is
similar to the main() function in C/C++.
This is starting point for the interpreter to
begin the execution of the program. A JAVA
can have many classes but only one of them
must include main method to initiate the
execution.

The main line contains number of


keywords , public, static & void
Public:- the keyword public is an access specifier that
declares the main method as unprotected and
accessible to all other classes. (similar to the C++
public modifier)
Static:- the static keyword which declares this
method as one that belongs to the entire class and
not part of any object of class.
Void:- void states that main method does not return
any value (but simply prints some text to the screen)

All parameter to a method are declared


inside a pair of parentheses. String
args[] declares parameter named args,
which contain an array of objects of
class type String.

First we have to import scanner through { import java.util.Scanner;}


Eg:class apples{
public static void main(String args[])
{
Scanner argus =new Scanner( System.in); \* to get input in argus variable*\
str=argus.nextLine(); \* to get string*\
wno=argus.nextInt(); \* to get whole no. or integer*\
fno=argus.nextFloat(); \ * to get float *\
Dno=argus.nextDouble(); \ * to get double*\
--------------------------------------}
argus variable name; we need variable to hold input from keyboard
System.in command to take input form keyboard

Вам также может понравиться