java language:-
java is a
programming language as well as a plateform
java is a high
level ,robust,secured object oriented progrmming language.
Plateform:-any
hardware & soft ware environment
use of java :-
desktop
Application,web application,mobile application smart card,robotics
types of java
Application :
1)standerd
Application(SE- eidition)
2)web
application(WE)
3) enterprise
Application(EE)
4) mobile
Application /micro Application (ME)
java(OAK)is
introduced in 1991 by james gosling,mike sheridan,patrick naughton with a small
green team
and in 1995 the
name of OAk was changed by JAVA
features of java:
1)simple
2)object-oriented
3)plateform
independent
4)secured
5)Architectural
Neutral-
7)portable
8)dynamic
9)multithreaded
10)distributed
Object oriented:
1polymorphism
2 abstraction
3inheritance
4 encapsulation
5 class
6 object
Simple program of
JAVA:
--------------------------------------
c++ program
=============
void main()
{
cout<<"hello";
}
-----------------------------------------
class Abc
{
public static
void main(String args[])
{
System.out.println("hello");
}
}
--------------------------------------------------------------------
class - is a
keyword to declare a class
public: key word is an access modifier which
represent the visiblity of the class
static- is a key word if we declare any method as
a static ,it is known as static method,and for the static method we dont
need to create any object the main method
is executed by jvm so it dosn't recuire to create object.
void : is
a return type of the method ,it means it will not return any value to the
operating system
main:- is the excuttion part of the
program(means startup of the program)
String args[]- it
is used at the time of command line argument
System.out.print:
is used to print the statement on the console
System(Class),Out(subfolder),print(mrthod)
variable
declaration:
variable is a
name of memory space
1 local variable:
declare inside the method
2 instance
variable: declare inside the class but out side the method
3 static variable
:variable declare with static keyword
class Abc
{
int a,b,c;
void add()
{
a=5;
b=6;
c=a+b;
Syatem.out.println(c);
}
public static
void main(String args[])
{
Abc a=new Abc();
a.add();
}
}
using Scanner
Class:
********************
import java.util.Scanner;
class Abc
{
public static
void main(String args[])
{
Scanner sc=new
Scanner(System.in);
System.out.print("enter
your roll no");
int
roll_no=sc.nextInt();
System.out.print("enter
your name");
String
name=sc.next();
System.out.print("enter
your fee");
int
fee=sc.nextInt();
System.out.println("RollNo"+roll_no+"Name"+name+"Fee"+fee);
("rollno"+roll_no)
}
now save with a
ScannerClass.java
go to cmd
go to desired
folder
compile with :
javac ScannerClass.java
run with:
java ScannerClass
command line :
--------------
class CommandLine
{
public static
void main(String args[])
{
int a,b;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
int c=a+b;
System.out.println(c);
}
}