Sie sind auf Seite 1von 93

COMPLETE JAVA NOTES

KARTHIKEYAN NOTES
JAVA SYLLABUS 45 Hours
Class: 1
1 Introduction of Java language
2 Data types
3 Access specifies
4 Difference between class and methods
5 onversion or !rapper classes
" #asic $rograms
Class: 2
% &perators
' If ondition
( )or *oop
1+!hile
11Do while
12,witch
Class: 3
13Array -ethods
14,tring -ethods
Class: 4
15lass and &b.ect
1"alling method
1%-ethod overloading
1'-ethod overriding
1(onstructor
2+)inali/e
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 5
21,tatic method and ,tatic members
220his 1eyword
23)inal 1eyword
24,uper 1eyword
Class: 6
25Abstract lass
2"Interface
2%Inheritance
Class: 7
2'$ac1age reation
2(23ception 4andling
Class: 8
3+Introduction to 5til pac1age
31Date class
326ector class
33Array*ist class
34*in1*ist class
354ash,et class
3"0ree,et class
Class: 9
3%Input and &utput ,tream classes and methods
Class: 10
3'Introduction to 7etwor1ing pac1age
3(58* lasses
4+58*onnection lasses
41I7etAddress lasses
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 11
42,oc1et lasses
43,erver,oc1et lasses
44lient,oc1et lasses
45Datagram$ac1et lasses
4"Datagram,oc1et lasses
Class: 12
4%Introduction of multithreading
4'23tends 0hread
4(Implements 0hread
Class: 13
5+Introduction of JD#
51onnection between -s Access to .ava with &D#
Class: 14
52Introduction to Applet
53#asic Applet programs
54olor lass
55)ont lass
Class: 15
5"Introduction to 9raphics
5%*ine method
5'8ectangle method
Class: 16
5($olygon method
"+&val method
"1Arc method
"2Image classes:
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 17
"3Introduction to A!0 components
"4*abel lass
"50e3t )ield lass
""#utton lass
"%$anel lass
Class: 18
"'Introduction to 2vents
"(-ouse 2vents
%+;eyboard 2vents
%1Item 2vents
Class: 19
%20e3t Area lass
%3,crollbar lass
%4hec1bo3 lass
%5hec1bo3 9roup lass
Class: 20
%"hoice lass
%%*ist lass
%')rame lass
%(-ouse ursor lass
Class: 21
'+-enu bar lass
'1$opup -enu lass
'2anvas lass
Class: 22
'3Introduction of *ayout
'4)low*ayout lass
'59rid*ayout lass
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
'"#order*ayout lass
'%ard*ayout lass
Class: 23
''Introduction to swings
'(,wings ontrols or omponents
(+,wings !indows
(1,wings $rograms
Class: 24
(2-essage bo3
(30imer lass
(4$rogress#ar lass
(5Dialog lass
Class: 25
(",wings -enus lass
(%,wings ontainer
(',wings $rograms
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
To set te !"#" $"t%
Way to set the java Path:
8ight clic1 to -y computer go to propertieslic1
9o to 2nvironment variables lic1
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
9oto 5ser variable for Administrator lic1 7ew #utton
0hen clic1 &1 &1 &1
Go to Dos command chec the java !ath:
,tart 8un md &1
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 1
"nt#od$ct%on o& 'ava lan($a(e:
Java developed by sun micro system corporation:
Java is plat form software
Java is a general purpose
Java is a pure oops concept
&b.ect oriented language was developed by sun micro system of
5,A in 1((1
&riginally it is called as &A; by James gosling< one of the
inventor of the language
Java was designed for the development of software for
consumer electronics devices li1e microwave ovens and remote
controls
In the year 1((5 :&A; replaced as .ava then we used to
Internet concept
Java is the platform independent language: =It means write once
and run anywhere>
4ere program name and class name are same
Java is the first programming that is not tied to any particular
operating system
Java is an Internet programming language
Java is a case sensitive
)s%n( so&t*a#e:
1: Java any version
2: 7et bean ":+
3: 2clipse 3:+
'ava call%n( ste!s:
$ac1age lasses-ethods
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
'ava !#o(#ams d%v%ded %nto 2 ty!es:
1: Application programming
0hat program is based on console?based runner
2: Applet programming =used for internet concept>
0hat program is based on web design and development>
+eat$#es o& 'ava
1: $latform Independent
2: ompiler and interpreter
3: &&$s
4: ,ecurity
5: $ortability
": Distributed application =8-I< ,oc1ets>
%: -ulti threading programming
,ynta- &o# com!%le#:
Javac @file nameA:.ava
,ynta- &o# "nte#!#ete#:
Java @file nameA
Way o& e-ec$t%on:
ompiler Interpreter
,ource ode ????????????#yte ode???????????? &utput
'ava P#o(#am ,t#$ct$#e
lass @class nameA
B
C@Access ,pecifiesAD
$ublic static void main =,tring argCD >
B
@,tatementsAE
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
F
P./G.01 232C)4"/5:
,tart notepad type your program
,ave your program @file nameA:.ava
4o see o$t!$t:
0hen go to D&, command compile the program
0hen run the .ava program in console
,tart 8unmd or command =2nter>
9o to your )older Area
ompile
8un
,ee output
Constants o& ,ystem classes
out for output
in for input
err for error
e3it for terminate the program e3ecution
5otes:
Data"n!$t,t#eam:
lass are first sound letter start with capital letter and every sound also
start with capital letter
!a#se"nt67:
-ethods are first sound letter start with small letter and other every
sound also start with capital letter
#ead8%ne6 7:
5sed to get input from user at run time
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
D%&&e#ence 9et*een C:: and '0;0:
C::
'0;0
&perating overloading 7ot
,upports all 1inds of
inheritance
&nly single< multi level others
achieved by interface concept
Delete operator to destroy the
resource
7ot available
,upport destructor methods 0here< finali/e => is used
,upport pointers 7ot use
)riend function specifies 7ot use
out@@ ,ystem:out:println
inAA d:read*ine=>
)uncitons -ethods
Ginclude@iostream:hA import .ava:io:HE
'ava 4y!es
JD; Java Development ;it
J6- Java 6irtual -achine
J,* Java ,tandard *ibrary
Data ty!es:
Data ty!es <yte
Int 4 bytes
*ong int ' bytes
har 2 bytes
)loat ' bytes
Double 1" bytes
,tring
= , should be capital because default data
7o need
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
type is string>
0ccess s!ec%&%es:
$ublic all any where
$rivate Access within only the function not for other classes
$rotected only used for Inheritance oncept
$ac1age 5sed for calling pac1age access
<as%c P#o(#ams:
2(:
II0o display my name
class p1
B
public static void main=,tring sCD>
B
,ystem:out:print=J1arthi1eyanJ>E
F
F
2(:
II2g for Data types
class p2
B
public static void main=,tring argCD>
B
int iK1+E
char cKL/LE
double dK1+:++E
float fK1+:5+fE
,tring sKJ1arthi1eyanJE
,ystem:out:println=Jint value isMJNi>E
,ystem:out:println=Jchar value isMJNc>E
,ystem:out:println=Jdouble value isMJNd>E
,ystem:out:println=Jfloat value isMJNf>E
,ystem:out:println=Jstring value isMJNs>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
F
F
Conve#s%on o# W#a!!e# classes:
5sed to convert data type from one data type to another data type
Data ty!e Conve#s%on
Int Integer:parsInt=d:read*ine=>>E
har har:parsehar=d:read=>>E
&r
=char>d:read=>E
)loat )loat :parse)loat=d:read*ine= >>E
Double Double:parseDouble=d:read*ine=>>E
,tring 7o need because default data type is ,tring
2(:
=I2g for character conversion
import .ava:io:HE
class p4
B
public static void main=,tring argCD>throws 23ception
B
char cE
DataInput,tream dKnew DataInput,tream=,ystem:in>E
,ystem:out:print=J2nter any characterMJ>E
cK=char>d:read=>E
,ystem:out:print=Jcharacater isMJNc>E
F
F
2-ce!t%on:
,ome abnormal condition an error can be occurring to avoid this error
we can use e3ception concept
2nd the main function use throws 23ception
5sing pac1age import .ava:io:HE
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 2
/!e#ato#s:
&perator is a ,ymbol< !hich is used to do some arithmetic &perations
0#%thmet%c /!e#ato#:
/!e#ato# 1ean%n(
N Addition
? ,ubtraction
H -ultiplication
I Division
O -odulus =After division
8emainder>
.elat%onal /!e#ato#:
&perator -eaning
A 9reater 0han
@ *esser than
AK 9reater than or ePual to
@K *ess than or ePual to
K K 2Pual to
@ A <Q K 7ot 2Pual t
8o(%cal /!e#ato#:
&perator -eaning
RR A7D =#oth condition 0rue>
SS &8 =Any one condition 0rue>
Q 7&0
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
0ss%(nment /!e#ato#:
&perator -eaning
NK
?K
HK
IK
)na#y /!e#ato#:
&perator -eaning
aNN $ost increment
NNa $re Increment
a?? $ost Decrement
??a $re Decrement
Cond%t%onal /!e#ato#:
onditional operator is used to chec1 condition
,ynta-:
=@onditionA>T @0rue statementA M @false statementAE
,!ec%al /!e#ato#:
&perator -eaning
B *eft #race
F
8ight #race
= *eft $arenthesis
> 8ight $arenthesis
C *eft ,Puare #rac1et
D 8ight ,Puare #rac1et
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for Arithmetic operator
import .ava:io:HE
class p3
B
public static void main=,tring argCD>throws 23ception
B
DataInput,tream dK new DataInput,tream=,ystem:in>E
int a<bE
,ystem:out:print=J2nter the a valueMJ>E
aKInteger:parseInt=d:read*ine=>>E
,ystem:out:print=J2nter the b valueMJ>E
bKInteger:parseInt=d:read*ine=>>E
,ystem:out:println=JAddition isMJN=aNb>>E
,ystem:out:println=J,ubtraction isMJN=a?b>>E
,ystem:out:println=J-ultiplication isMJN=aHb>>E
,ystem:out:println=JDivision isMJN=aIb>>E
,ystem:out:println=J-odulus isMJN=aOb>>E
F
F
"& Cond%t%on
If condition< 2lse if condition< *adder If condition< 7ested If condition
,ynta- &o# %& cond%t%on:
If =@conditionA>
B
@ 0rue statementsAE
F
else
B
@ )alse statementsAE
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for if condition
import .ava:io:HE
class p5
B
public static ,tring u<pE
public static void main=,tring argCD>throws 23ception
B
DataInput,tream dKnew DataInput,tream=,ystem:in>E
,ystem:out:print=J2nter the user nameMJ>E
uKd:read*ine=>E
,ystem:out:print=J2nter the passwordMJ>E
pKd:read*ine=>E
if=u:ePuals=J1arthiJ>RR=p:ePuals=JbssJ>>>
B
,ystem:out:print=J*ogin M ,52,,J>E
F
else
B
,ystem:out:print=J*ogin M )AI*2DJ>E
F
F
F
+o# 8oo!:
0hey have 3 function 1> starting value 2> condition 3> inc or Dec
,ynta- &o# no#mal &o# loo!:
for =@variable nameA K @starting AE @conditionAE @Inc I DecA>
B
@,tatementsAE
:
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II0o display table format by using for loop
import .ava:io:HE
class p"
B
public static void main=,tring argCD>throws 23ception
B
int n<c<iE
DataInput,tream dKnew DataInput,tream=,ystem:in>E
,ystem:out:print=J2nter which table u wantMMJ>E
nKInteger:parseInt=d:read*ine=>>E
,ystem:out:print=J2nter how many number u wantMJ>E
cKInteger:parseInt=d:read*ine=>>E
for=iK1Ei@KcEiNN>
B
,ystem:out:println=iNJHJNnNJKJN=iHn>>E
F
F
F
Wh%le:
In while first they chec1 condition after given true statements are
e3ecuted
,ynta- &o# *h%le cond%t%on:
!hile =@conditionA>
B
@ 0rue statementsAE
:
:
:
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for while
class p%
B
public static void main=,tring argCD>
B
int iK1E
,ystem:out:println=JDisplay odd number 1 to 1+J>E
do
B
,ystem:out:println=i>E
iKiN2E
F
while=i@1+>E
F
F
Do *h%le:
Do !hile first given statements are e3ecuted after they chec1 condition
Do while statements end with semicolon
,ynta- &o# do *h%le cond%t%on:
do
B
@ 0rue statementsAE
:
:
:
F
!hile =@conditionA>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for do while
class p'
B
public static void main=,tring argsCD>
B
int iK1E
do
B
int .KiH5E
,ystem:out:println=iNJH5KJN.>E
iNNE
F
while=i@K1+>E
F
F
,*%tch:
0hey chec1 a condition by case format
ase should be end with colon not for semicolon
,ynta- &o# s*%tch:
switch=@23pA>
B
case @23p1AM
@,tatementsAE
brea1E
case @23p2AM
@,tatementsAE
brea1E
:
defaultM
@ default statementsAE
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for switch
class p(
B
public static void main=,tring argsCD>
B
int iK1E
switch=i>
B
case +M
,ystem:out:println=J0he case UeroJ>E
brea1E
case 1M
,ystem:out:println=J0he case &neJ>E
brea1E
defaultM
,ystem:out:println=JDefaultJ>E
brea1E
F
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 3
0##ay 1ethods:
Array means declare one variable store more than one value in same
data type as in same variable name is called array
4hey a#e t*o ty!es %n 0##ay:
1> ,ingle Dimensional Array
2> -ulti Dimensional Array
,ynta- &o# s%n(le d%mens%onal a##ay:
@Data typeA @var1AC D K new @data typeA C @si/eA DE
,ynta- &o# 0##ay %n%t%al%>at%on:
@Data typeA @var1A C D K B@valuesAFE
=&r>
@Data typeA C D @var1A K B@valuesAFE
8en(th:
5sed to find the 0otal si/e of array
,ynta- &o# len(th:
@6ariable nameA:length
1$lt% d%mens%onal a##ay:
-ulti dimensional array is mostly used for matri3 addition or matri3
,ubtraction or matri3 multiplication
,ynta- &o# 1$lt% d%mens%onal a##ay:
@Data typeA @var1A C D C D K new @data typeA C@si/eAD C@si/eADE
,ynta- &o# 0##ay %n%t%al%>at%on:
@Data typeA @var1A C D C D K B@valuesAF B@valuesAFE
=&r>
@Data typeA C D C D @var1A K B@valuesAF B@valuesAFE
2(:
int a C D C D K B 34<23<"%<%4F B34<12<5"<23 FE
=&r>
int C D C Da K B 34<23<"%<%4F B34<12<5"<23 FE
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for Array intiali/ation
class p11
B
public static int aCDKB1<5<4<12<1'FE
public static int iE
public static void main=,tring argCD>
B
,ystem:out:println=JArray value areMJ>E
for=iK+Ei@a:lengthEiNN>
B
,ystem:out:println=aCiD>E
F
F
F
2(:
II2g for Array run time value
import .ava:io:HE
class p12
B
public static int aCDKnew intC5DE
public static int iE
public static void main=,tring argCD>throws 23ception
B
DataInput,tream dKnew DataInput,tream=,ystem:in>E
,ystem:out:println=J2nter the five valuesMJ>E
for=iK+Ei@a:lengthEiNN>
B
aCiDKInteger:parseInt=d:read*ine=>>E
F
,ystem:out:println=J9iven Array value areMJ>E
for=iK+Ei@a:lengthEiNN>
B
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ystem:out:println=aCiD>E
F
F
F
2(:
II2g for double dimensional Array intiali/ation
class p13
B
public static int aCDCDKB1<5F B12<1'FE
public static int i<.E
public static void main=,tring argCD>
B
,ystem:out:println=JArray values areMJ>E
for=iK+Ei@a:lenghtEiNN>
B
,ystem:out:print=JVnVnJ>E
for=.K+E.@a:lengthE.NN>
B
,ystem:out:print=aCiDC.D>E
,ystem:out:print=JVtVtJ>E
F
F
F
F
2(:
II2g for character array
class p14
B
public static void main=,tring arCD>
B
,tring sKnew ,tring=J0his is my ,tringJ>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ystem:out:println=s:length=>>E
char cCDKnew charCs:length=>DE
cKs:toharArray=>E
,ystem:out:println=c>E
for=int iK+Ei@c:lengthEiNN>
B
,ystem:out:println=iNJ MJNcCiD>E
F
F
F
2(:
II2g for multidimensional array
class p15
B
public static void main=,tring argCD>
B
int rK1+E
int cK1+E
int pCDCDKnew intCrDCcDE
,ystem:out:println=J-ultiliplication 0ableJ>E
,ystem:out:println=J J>E
for=int iK1Ei@rEiNN>
B
for=int .K1E.@cE.NN>
B
pCiDC.DKiH.E
,ystem:out:println=iNJ H JN . N JMK JNpCiDC.D>E
F
,ystem:out:println=J J>E
F
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,t#%n( 1ethods:
,tring means more than one character
4ere we donWt use any pac1age
THANKING YOU
CREATED BY A.KARTHIKEYAN
,?5/ ,ynta- &o# methods 1ean%n(
1
@s1A: to5pperase= >
onvert lower case to upper case
2
@s1A: to*owerase= >
onvert upper case to lower case
3
@s1A:length= >
)ind the length of string
4
@s1A:charAt=@nthA > Display given nth position of
character
5
@s1A:sub,tring=@start
posA<@ up to no of
characterA >
23tract given character from the
string
"
@s1A:inde3&f=@charA>E Display first occurrence of the
character position
%
@s1A:lastInde3&f=@charA>E Display last occurrence of the
character position
'
@s1A:reverse=>E
8everse the given string
(
concat=@s1A<@s2A>E
Attach two strings
1+
@s1A:starts!ith=@charA> ,tring starts from the given
character
11
@s1A:ends!ith=@charA> ,tring ends from the given
character
12
@s1Atrim=>E 8emove white spaces front and
bac1
13 @s1A:ePuals=@s2A>
hec1 two string are ePual or not
if return K+ ePual else not ePual
14
@s1A:ePualsIgnorease=@s2
A
hec1 two string are ePual or not
but it ignore the case sensitive
COMPLETE JAVA NOTES
2(:
II2g for stringmethod
class p12
B
public static void main=,tring argCD>
B
,tring s1KJ1arthi1JE
,tring s2KJ;2XA7JE
,tring s3KJ .ava
JE
,tring s4KJ;A804I;JE
,ystem:out:println=J5pper case
isMJNs1:to5pperase=>>E
,ystem:out:println=J5pper case
isMJNs2:to*owerase=>>E
,ystem:out:println=J*ength of s1 isMJNs1:length=>>E
,ystem:out:println=Js1 3 rd position char
isMJNs1:charAt=3>>E
,ystem:out:println=J,ubstring of s1
isMJNs2:substring=2<4>>E
,ystem:out:println=Js1 r position isMJNs1:inde3&f=L1L>>E
,ystem:out:println=Js1 r position
isMJNs1:lastInde3&f=L1L>>E
II,ystem:out:println=Js1Ns2 MJNconcat=s1<s2>>E
II,ystem:out:println=Jstarts with t
isMJNs1:starts!ith=LtL>>E
II,ystem:out:println=J2nd with t isMJNs2:ends!ith=LXL>>E
,ystem:out:println=J!ithout removing spaceMJNs3>E
,ystem:out:println=J8emoving spaceMJNs3:trim=>>E
if=s1:ePualsIgnorease=s4>>
B
,ystem:out:println=Js1 and s4 string are 2PualJ>E
F
else
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
,ystem:out:println=Js1 and s4 string are 7ot
2PualJ>E
F
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 4
Class and /9ject:
lass means collections of methods R members or variables
An ob.ect is an instance of a class which is used to access members of
class
Class Decla#at%on synta-:
class @class nameA
B
@ Declaration partsAE
:
:
:
F
class @class name or program nameA
B
@main functionA= >
B
@class nameA @ob.ect nameA K new @class nameA= >E
@&b.ect nameA:@membersAE
@&b.ect nameA:@methodsA=argsC D>E
:
F
F
2(:
II2g for class and ob.ect
class demo1
B
public static void disp=>
B
,ystem:out:println=J4ai this is first class methodJ>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
class demo2
B
public static void disp=>
B
,ystem:out:println=J4ai this is second class methodJ>E
F
F
class demo3
B
public static void disp=int 3<,tring n>
B
,ystem:out:println=Jlass3 int 3 value isMJN3>E
,ystem:out:println=Jlass3 ,tring n value isMJNn>E
F
F
class p14 e3tends demo1
B
public static void main=,tring argCD>
B
disp=>E
demo2 s1Knew demo2=>E
s1:disp=>E
demo3 s2Knew demo3=>E
s2:disp=1+<J1arthiJ>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Call%n( 1ethods:
alling -ethods are function that operate on instant of classes are
which they are defined ob.ect can communicate with each other: 5sing
methods R can call methods in other classes
,ynta- &o# +$nct%on o# methods Decla#at%on:
@ 8eturn typeA @method nameA = >
B
@ ,tatements AE
:
F
0#($ment methods:
)unctions have any argument that methods have argument methods
,ynta- &o# 0#($ments:
@ &b.ect nameA: @ method nameA=@type1A<@type2A>E
2(:
II2g for alling members and Argument methods
import .ava:io:HE
class demo
B
public static ,tring n<dE
public static int sE
public static void show=,tring a<,tring b<int c>
B
,ystem:out:println=J7ame isMJNa>E
,ystem:out:println=JDesignation isMJNb>E
,ystem:out:println=J,alary isMJNc>E
F
F
class p3+ e3tends demo
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
public static void main=,tring argC D> throws 23ception
B
p3+ ss K new p3+= >E
ss:nKJ1umarJE
ss:dKJsoftware 2ngineerJE
ss:sK1++++E
ss:show=ss:n<ss:d<ss:s>E
F
F
1ethod ove#load%n(:
,ame function name or methods name but different types of arguments is
called method overloading

,ynta- &o# method ove#load%n(:
@ 8eturn typeA @same method nameA =@different ArgA>
B
@ ,tatements AE
F
@ 8eturn typeA @same method nameA =@different ArgA>
B
@ ,tatements AE
F
2(:
II2g for -ethod overloading
import .ava:io:HE
class demo
B
public static void show=int 3<int y>
B
,ystem:out:println=J3 value isMJN3>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ystem:out:println=Jy value isMJNy>E
F
public static void show=,tring .<,tring 1>
B
,ystem:out:println=J. name isMJN.>E
,ystem:out:println=J1 name isMJN1>E
F
F
class p31 e3tends demo
B
public static void main=,tring argC D >throws 23ception
B
p31 sKnew p31= >E
s:show=1+<5>E
s:show=J1arthiJ<JsenthilJ>E
F
F
1ethod /ve##%d%n(:
,ame method name and same types of arguments are called method
overriding
Const#$cto#:
onstructor when and ob.ect is created for class it call automatically
4ere you donWt use return type in front of methods name
.$les o& ma%n( const#$cto#:
onstructor method name must name must be same as class name
onstructor does not return any values: ,o we donWt use return type
onstructors have arguments
4y!es o& const#$cto#:
Default constructor or 2mpty constructor
$arameter constructor or Argument constructor
4ere we donWt use opy constructor
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
De&a$lt const#$cto# o# em!ty const#$cto#:
onstructor methods have without any argument is called default
constructor or empty constructor
0#($ment const#$cto# o# !a#amete# const#$cto#:
onstructor methods have any argument is called argument constructor
or parameter constructor
2(:
II2g for onstructor
class demo
B
public demo=>
B
,ystem:out:println=J0his is empty constructorJ>E
F
public demo=int 3<float f<,tring s>
B
,ystem:out:println=JY value isMJN3>E
,ystem:out:println=J)loat value isMJNf>E
,ystem:out:println=J,tring s valueMJNs>E
F
F
class p1%
B
public static void main=,tring argCD>
B
demo dKnew demo=>E
demo d1Knew demo=1+<1':24f<J.avaJ>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
+%nal%>e:
Finalize method or function is contradiction (opposition) to the
constructor method
The finalize method is represented by the keyword finalize
,ynta- &o# &%nal%>e:
$rotected void finali/e = >
B
@,tatementsAE
F
!e use only #oolean data type to chec1 either true or false
2(:
II2g for finali/e concept
class demo
B
public demo=>
B
,ystem:out:println=J-emory is allocatedJ>E
F
protected void finali/e=>
B
,ystem:out:println=J-emory is deallocatedJ>E
F
F
class p1'
B
public static void main=,tring argCD>
B
while=true>
B
demo sK new demo=>E
F
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 5
,tat%c method and ,tat%c mem9e#s:
,tatic variable can be initiali/ing only once
All ob.ects that are initiali/ed /ero automatically share static members
,tatic method only allows a static member or static variables
,tatic methods are called without ma1ing ob.ect
!ithout using ob.ect we can call function by using static 1eyword
2(:
class statictest
B
static int countK+E
public statictest=>
B
countNNE
F
public void display=>
B
,ystem:out:println=count>E
F
public static void main=,tring aCD>
B
statictest sKnew statictest=>E
s:display=>E
statictest s1Knew statictest=>E
s1:display=>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
4h%s ey*o#d:
+%nal ey*o#d:
,$!e# ey*o#d:
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 6
09st#act Class:
Abstract class is an incomplete class:
It is an collection of abstract behaviors of its sub classes
Instance cannot be created using abstract class:
,ub classes can in heritance variables R methods from them:
lasses that cannot be instantiated directly Abstract classes e3ist:
,ynta- &o# 09st#act Class:
abstract class @ class name 1A
B
abstract @return type A @method name 1A= >E
IIoncrete methods are still allocated in abstract classes
F
2(:
abstract class ban1
B
abstract void balance=>E
F
2(:
class iciciban1 e3tends ban1
B
void balance=>
B
,ystem:out:println=JIciciban1 balanceMJN5<++<+++J>E
F
F
2(:
class indianban1 e3tends ban1
B
void balance=>
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
,ystem:out:println=JIndian #an1MJN'<++<+++J>E
F
F
2(:
class sbiban1 e3tends ban1
B
void balance=>
B
,ystem:out:println=J,#I #alanceJN1<++<+++J>E
F
F
2(:
class p22
B
public static void main=,tring argCD>
B
sbiban1 s1Knew sbiban1=>E
s1:balance=>E
iciciban1 s2Knew iciciban1=>E
s2:balance=>E
indianban1 s3Knew indianban1=>E
s3:balance=>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
"nte#&ace:
Interface is a collection of abstract behaviors that individual classes can
implements
Interface designed to support dynamic method =random methods> or to
access same name methods
5otes:
Implements are a 1eyword that used for implementing an interface a
class
,ynta- &o# %nte#&ace:
C@Access specifiesAD interface @interface nameA
B
@8eturn typeA @-ethods name1A= >E
F
class @base class nameA implements @interface nameA
B
@8eturn typeA @-ethods name1A= >
B
@,tatementsAE
F
F
class @derived class nameA implements @interface nameA
B
@8eturn typeA @-ethods name1A= >
B
@,tatementsAE
F
@-ain method statementsA= >
B
@,tatementsAE
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for interface concept
interface interface1
B
public void disp=>E
F
class base1 implements interface1
B
public void disp=>
B
,ystem:out:println=J0his is #ase class Interface J>E
F
F
class p23 implements interface1
B
public void disp=>
B
,ystem:out:println=J0his is Derived class Interface J>E
F
public static void main=,tring argCD>
B
p23 s1Knew p23=>E
base1 s2Knew base1=>E
s1:disp=>E
s2:disp=>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
"nhe#%tance:
reating a new class from an e3isting class
7ew class is called as derived or inherited class and the e3isting class is
called as base or super class
5otes:
4ere e3tends 1eyword is used to call base class to another derived class
4y!es o& %nhe#%tance:
1? ,%n(le "nhe#%tance
2? 1$lt%level "nhe#%tance
3? 1$lt%!le "nhe#%tance 6not s$!!o#ted he#e7
4? @%e#a#chal "nhe#%tance
5? @y9#%d "nhe#%tance 65ot s$!!o#ted he#e7
Java doesnWt supported -ultiple inheritance and 4ybrid Inheritance
It can be achieved by interface concept
,%n(le %nhe#%tance:
,ingle Inheritance as one base class and one derived class
1$lt%level "nhe#%tance:
-ultilevel has one pure base class and one as act as a base and also
derived and another one as pure derived class
1$lt%!le %nhe#%tance:
-ultiple inheritances as many base classes and one derived class
=It can be achieved by Interface concept and implements 1eyword>
@%e#a#chal %nhe#%tance:
4ierarchal has one base class and two or more than two derived classes
=It can be achieved by Interface concept and implements 1eyword>
@y9#%d %nhe#%tance:
0he combination of multiple Inheritance and multilevel Inheritance
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for single inheritance
class ,ingle
B
int aE
public
void 9et=>
B
aK1+E
F
F
class -a1e e3tends ,ingle
B
void Display=>
B
,ystem:out:println=JAMKJNa>E
F
F
class ,ingleZinh
B
public static void main=,tring argCD>
B
-a1e sKnew -a1e=>E
s:9etZData=>E
s:Display=>E
F
F
2(:
II2g for multiple inheritance
class data1
B
int d1E
public void getZd1=>
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
d1K"%E
F
F
interface data2
B
int d2K5"E
void mul=>E
F
class multiple e3tends data1 implements data2
B
int totE
public void mul=>
B
totKd1Hd2E
F
public void display=>
B
,ystem:out:println=JtotalKJNtot>E
F
F
class multi
B
public static void main=,tring argCD>
B
multiple sKnew multiple=>E
s:getZd1=>E
s:mul=>E
s:display=>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
IH-ultilevel InheritanceHI
class ,tudent
B
int rnoE
void 9et1=int 3>
B
rnoK3E
F
void $ut1=>
B
,ystem:out:println=J8ollZ7umberMKJN rollZno>E
F
F
class 0est e3tends ,tudent
B
int sub1<sub2E
void 9et2=int m1<int m2>
B
sub1Km1E
sub2Km2E
F
void $ut2=>
B
,ystem:out:println=J-ar11MKJNsub1>E
,ystem:out:println=J-ar12MKJNsub2>E
F
F
class 8esult e3tends 0est
B
float totalE
void Disp=>
B
totalKsub1Nsub2E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
$ut1=>E
$ut2=>E
,ystem:out:println=J0otalMKJNtotal>E
F
F
class -ultiZlevel
B
public static void main=,tring argCD>
B
8esult sKnew 8esult=>E II&b.ect creation
s: 9et1=111>E
s:9et2=1++<1++>E
s:Disp=>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 7
Paca(e C#eat%on:
$ac1ages are nothing but it is a [class \ libraries]
$ac1ages are nothing but it is collection of methods and various classes:
'ava Paca(e "s 2 4y!es:
1> Java Application $rogramming Interface $ac1age =A$I $ac1age>
=&r> ,ystem Defined pac1age
2> 5ser Defined $ac1age
,ystem De&%ned Paca(es:
import .ava:lang:H *anguage ,upport classes automatically imported
import .ava:util:H date and time< 6ector etc
import .ava:io:H InputIoutput &perations
import .ava:applet:Hlasses for creating and implementing applets
import .ava:awt:H ,et of classes implementing 95I
import .ava:net:H lasses for networ1ing
,te!s to c#eate !aca(e:
1> reate a new folder when it has same name of pac1age name
2> 4ere pac1age name and folder name are same
3> Include the pac1age command< along with the pac1age name as the
first statements in the program name
4> !rite class declaration
5> ,ave the file in pac1age folder as [7ame of class .ava]
"> ,et the class path K O class pathO E dMV@pac1age name A
%> ompile this file using .avac
,ynta- &o# !aca(e c#eat%on:
pac1age @pac1age name or folder nameA :C@sub pac1age nameADE
public class @class name A
B
public static ,tring @method nameA=,tring argC D>
or
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
public static @method nameA= >
B
@statementsAE
F
F
2(:
II2g for pac1age creation
pac1age deviceE
public class input
B
public static show= >
B
,ystem:out:println=[VnInput device areM]>E
,ystem:out:println=[VnVt;eyboard]>E
,ystem:out:println=[VnVt-ouse]>E
,ystem:out:println=[VnVt,canner]>E
,ystem:out:println=[VnVt*ight $en]>E
,ystem:out:println=[VnVt#arcode reader]>E
F
F
1> ,ave the file to your pac1age folder input: Java
2> ,et the DMV1arthiVdeviceAset path K DMV.d11:"Vbin
3> ompile this file using .avac:
2(:
II2g for pac1age creation
pac1age device
public class output
B
public static show= >
B
,ystem:out:println=[Vn&utput device areM]>E
,ystem:out:println=[VnVt-onitor]>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ystem:out:println=[VnVt$rinter]>E
,ystem:out:println=[VnVt,canner]>E
F
F
1> ,ave the file to your pac1age folder output: Java
2> ,et the class path K O class pathO E dMV@pac1age name A
3> ompile this file using .avac:
,ynta- &o# $s%n( !aca(e classes:
import @pac1age nameA:HE
@access specifier A class @class nameA
B
@main methodA=,tring argC D>
B
@class nameA @ob. nameA K new @class nameA= >E
@ob. nameA: @method nameA= >E
@statementsAE
F
F
2(:
II0o display pac1age methods
import device:HE
public class p4(
B
public static void main=,tring argC D>
B
input s K new input= >E
output dK new output= >E
s:show= >E
d:show= >E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2-ce!t%on @andl%n(:
,ome abnormal conditions an error can be occur to avoid this error we
can use 23ception concept
4hey a#e 5 ty!es:
1> 0ry
2> atch
3> 0hrow
4> 0hrows
5> )inally
4ere all are 1eywords
4W/ <252+"4,:
0o allow you to fi3 the error
It prevents the program from automatically terminating
,/12 23C2P4"/5, 0.2:
2-ce!t%on Classes 5ames
1ean%n(
Arithmetic23ception Arithmetic error< such as divide
by /ero
I&23ception 9eneral problems during input
and output operators
ArrayInde3&ut&f#ounds23cepti
on
!hen array inde3 is out the
given range
Array,tore23ception
Assignment to the array element
of an incompatible by array
inde3
7ull$ointer23ception
Invalid use of null reference
InterruptedI&23ception
&ne thread has been interrupted
by another thread
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
)ile7ot)ound23ception
!hen a rePuested file is not
found
2&)23ception 2nd of file reached e3ception
error
,^*23ception
!hen error occurs during a
database access
5n1nown*ost23ception
!hen the host cannot be located
7umber)ormat23ception
!hen the string passes is not a
number
Gene#al synta- &o# t#y catch method:
try
B
@0ry bloc1 statementsAE
:
F
catch= 23ception @type1A>
B
@23ception handlersAE
:
F
catch= 23ception @type2A>
B
@23ception handlersAE
:
F
finally
B
@)inal statementsAE
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
4#y A Catch model
!henever there is a possibility of an e3ception being generated in a
program: It is a better to handler it e3plicitly
Immediately the following try bloc1 include a catch clause that specifies
the e3ception type that you using the catch
,ynta-:
try
B
@0ry bloc1 statementsAE
:
:
F
catch= 23ception @type1A>
B
@23ception handlersAE
:
:
F
1$lt% catch
-ore than one catch could be single piece of code: 0o handle this type
of situation you can specify are more than two catches
2ach catching different types of 23ception
,ynta-:
try
B
@0ry bloc1 statementsAE
:
:
F
catch= 23ception @type1A>
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
@23ception handlersAE
:
:
F
catch= 23ception @type2A>
B
@23ception handlersAE
:
:
F
4h#o*
0hrow is possible to throw an 23ception e3plicitly
0hey are two ways you can obtain a throwable ob.ect using a parameter
into a catch clause< or creating one with the new operator
,ynta- &o# th#o*:
throw @throwable instanceAE
4h#o*s:
0hrows does not to handle e3ception using try?catch bloc1: It can use
the main= > method is the program e3cepts the generation of arithmetic
e3ception but does not want to handle try catch bloc1:
,ynta-:
throws @23ception nameA
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
II2g for try catch method
import .ava:io:HE
public class p34
B
public static int a<b<cE
public static void main=,tring argC D>
B
try
B
DataInput,tream dK new DataInput,tream=,ystem:in>E
,ystem:out:println=J2nter the a valueMJ>E
aKInteger:parseInt=d:read*ine=>>E
,ystem:out:println=J2nter the b valueMJ>E
bKInteger:parseInt=d:read*ine=>>E
cKaIbE
,ystem:out:println=JDivision of two number isMJNc>E
F
catch=23ception e>
B
,ystem:out:println=JXou divided /eroJ>E
F
F
F
2(:
II2g for multicatch
import .ava:io:HE
class p3"
B
public static int i<.K2<c<aC DKnew intC5DE
public static void main=,tring argC D>
B
try
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
DataInput,tream dKnew DataInput,tream=,ystem:in>E
for=iK1Ei@K%EiNN>
B
,ystem:out:println=J2nter the JNiNJ valuesMJ>E
aCiDK Integer:parseInt=d:read*ine= >>E
cKaCiDI.E
,ystem:out:println=J9iven divide value isMJNc>E
.K.??E
F
F
catch=Arithmetic23ception e1>
B
,ystem:out:println=e1>E
F
catch=ArrayInde3&ut&f#ounds23ception e2>
B
,ystem:out:println=e2>E
F
F
F
2(:
II2g for throw 23ception
import .ava:io:HE
class p3%
B
public static void disp= >
B
try
B
throw new 7ull$ointer23ception=JdispJ>E
F
catch=7ull$ointer23ception e1>
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
,ystem:out:println=e1>E
throw= >E II8ecall the methods:
F
F
public static void main=,tring argC D>
B
try
B
disp= >E
F
catch=7ull$ointer23ception e2>
B
,ystem:out:println=e2>E
F
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 8
Date class:
It contains a collection util )ramewor1< collection classes
,ynta- &o# Date Class Decla#at%on:
9regorianalendar @ob. nameAKnew 9regorianalendar =>E
-ethod Declaration -eaning
@ob. nameA:get=alendar:DA02> Display Date
@ob. nameA:get=alendar:X2A8> Display Xear
@ob. nameA:get=alendar:-&704> Display -onth
@ob. nameA:get=alendar:DAX> Display Day
@ob. nameA:get=alendar:4&58> Display 4our
@ob. nameA:get=alendar:-I7502> Display -inute
@ob. nameA:get=alendar:,2&7D> Display ,econd
@ob. nameA:get=alendar:!22;Z&)ZX2A8> Display wee1 of year
@ob.
nameA:get=alendar:!22;Z&)Z-&704>
Display wee1 of
-onth
@ob. nameA:get=alendar:DAXZ&)Z-&704> Display day of month
@ob. nameA:get=alendar:DAXZ&)ZX2A8> Display day of year
@ob. nameA:get=alendar:DAXZ&)Z!22;> Display day of wee1
@ob. nameA:get=alendar:A-Z$-> Display A- or $-
@ob. nameA:get=alendar:4&58Z&)ZDAX> Display 4our of day
2(:
import .ava:util:HE
public class d1
B
public static void main=,tring sCD>
B
9regorianalendar cKnew 9regorianalendar=>E
,ystem:out:println=JX2A8M J N c:get=alendar:X2A8>>E
,ystem:out:println=J-&704M J N c:get=alendar:-&704>>E
,ystem:out:println=J!22;Z&)ZX2A8M J N
c:get=alendar:!22;Z&)ZX2A8>>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ystem:out:println=J!22;Z&)Z-&704M J N
c:get=alendar:!22;Z&)Z-&704>>E
,ystem:out:println=JDA02M J N c:get=alendar:DA02>>E
,ystem:out:println=JDAXZ&)Z-&704M J N
c:get=alendar:DAXZ&)Z-&704>>E
,ystem:out:println=JDAXZ&)ZX2A8M J N
c:get=alendar:DAXZ&)ZX2A8>>E
,ystem:out:println=JDAXZ&)Z!22;M J N
c:get=alendar:DAXZ&)Z!22;>>E
,ystem:out:println=JA-Z$-M J N c:get=alendar:A-Z$->>E
,ystem:out:println=J4&58M J N c:get=alendar:4&58>>E
,ystem:out:println=J4&58Z&)ZDAXM J N
c:get=alendar:4&58Z&)ZDAX>>E
,ystem:out:println=J-I7502M J N c:get=alendar:-I7502>>E
,ystem:out:println=J,2&7DM J N c:get=alendar:,2&7D>>E
F
F
;ecto# class:
6ector is a dynamic array
0hat can be holding an ob.ect as any data type and any number
,ynta- &o# vecto# class decla#at%on:
6ector @ob. nameA K new 6ector=@si/eA>E
,X70AY -204&D, 7A-2 -2A7I79
@ob. nameA:remove2lementAt =@nthA>E 8emove the item stored
in the nth position
@ob. nameA:add2lementAt =@itemA>E Add the item specified to
the list at the end
@ob. nameA:elementAt=@nthA>E 5sed to find out the nth
2lement or ob.ect
@ob. nameA:si/e= >E )ind out the si/e of
vector
@ob. nameA:remove2lement=@itemA >E 8emove the item stored
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
in nth position in the list
@ob. nameA:removeAll2lements= >E 8emove all 2lements in
the list
@ob.
nameA:insert2lementAt=@stringA<@posA>
E
Insert the string as given
position
@ob. nameA:capacity=>E )ind out the capacity of
vector
@ob. nameA:add=@stringA> Add item to vector
2(:
II2g for vector
import .ava:util:HE
class v1
B
public static void main=,tring ssCD>
B
6ector vKnew 6ector=3>E
,ystem:out:println=Japacity &f 6ectorMJNv:capacity=>>E
,ystem:out:println=Jsi/e of 6ectorMJNv:si/e=>>E
v:add2lement=JApolloJ>E
v:add2lement=J8osiJ>E
v:add2lement=JsupriaJ>E
,ystem:out:println=Japacity &f 6ectorMJNv:capacity=>>E
,ystem:out:println=Jsi/e of 6ectorMJNv:si/e=>>E
v:add=J,aranyaJ>E
,ystem:out:println=Jfourth elementMJNv:elementAt=3>>E
,ystem:out:println=Japacity &f 6ectorMJNv:capacity=>>E
,ystem:out:println=Jsi/e of 6ectorMJNv:si/e=>>E
v:add=new Integer=1+>>E
v:add=new )loat=1+:(f>>E
,ystem:out:println=Japacity &f 6ectorMJNv:capacity=>>E
,ystem:out:println=Jsi/e of 6ectorMJNv:si/e=>>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ystem:out:println=v>E
v:remove2lementAt=3>E
,ystem:out:println=JAfter 8emoving &ne 2lement apacity &f
6ectorMJNv:capacity=>>E
,ystem:out:println=Jsi/e of 6ectorMJNv:si/e=>>E
,ystem:out:println=v>E
2numeration eKv:elements=>E
while=e:has-ore2lements=>>
B
,ystem:out:println=e:ne3t2lement=>>E
F
F
F
0##ay8%st class:
2(:
import .ava:util:HE
class al
B
public static void main=,tring argsCD>
B
Integer i1Knew Integer=1+>E
Integer i2Knew Integer=2+>E
Integer i3Knew Integer=3+>E
Integer i4Knew Integer=4+>E
,tring s1Knew ,tring=J4aiJ>E
Array*ist aKnew Array*ist=>E
a:add=i1>E
a:add=i2>E
a:add=i3>E
a:add=i4>E
a:add=s1>E
,ystem:out:println=JArray list isMJNa>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
8%n8%st class:
synta- &o# 8%n8%st class:
*in1ed*ist @ob. nameAKnew *in1ed*ist=>E
1ethods:
@ob. nameA:add=@valueA>E
@ob. nameA:add)irst=@valueA>E
@ob. nameA:add*ist=@valueA>E
@ob. nameA:remove=@valueA>E
2(:
import .ava:util:HE
class ll
B
public static void main=,tring argsCD>
B
*in1ed*ist lKnew *in1ed*ist=>E
l:add=i1>E
l:add=i2>E
l:add=i3>E
l:add=i4>E
l:add=s1>E
l:add)irst=JYYYYYJ>E
l:add*ast=JXXXXXJ>E
,ystem:out:println=J JNl>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
@ash,et class:
2(:
import .ava:util:HE
class hs
B
public static void main=,tring argsCD>
B
4ash,et hKnew 4ash,et=>E
h:add=J2J>E
h:add=JDJ>E
h:add=JJ>E
h:add=J#J>E
h:add=JAJ>E
,ystem:out:println=J JNh>E
F
F
4#ee,et class:
2(:
import .ava:util:HE
class ts
B
public static void main=,tring argsCD>
B
0ree,et tKnew 0ree,et=>E
t:add=J4J>E
t:add=J9J>E
t:add=J)J>E
t:add=J2J>E
t:add=JDJ>E
t:add=JJ>E
t:add=J#J>E
t:add=JAJ>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ystem:out:println=J JNt>E
,ystem:out:println=J J>E
,ystem:out:println=J JNt:head,et=JDJ>>E
,ystem:out:println=J J>E
,ystem:out:println=J JNt:tail,et=JDJ>>E
,ystem:out:println=J J>E
,ystem:out:println=J JNt:sub,et=JDJ<J9J>>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 9
"n!$t and /$t!$t ,t#eam classes and methods:
,ynta- &o# +%le Class decla#at%on:
)ile @ob. nameAK new )ile=@path with file nameA>
)s%n( 1ethods 1ean%n(
@file ob.A:is)ile=> hec1 file or not display only true
or false
@file ob.A:isAbsolute=> 8eturn true if the file has an
absolute path else not absolute
@file
ob.A:rename0o=@newfnameA>
If true file name changed
@file ob.A:delete=> If true delete the file
@file ob.A:get7ame=> 8eturn name of the file without
path
@file ob.A:get$ath=> 8eturns the path given while
creating file ob.ect
@file ob.A:getAbsolute$ath=> 8eturn absolute path
@file ob.A:get$arent=> 8eturn full path of parent directory
@file ob.A:e3ists=> hec1 file is present or not
@file ob.A:can!rite=> hec1 writeable or not
@file ob.A:can8ead=> hec1 readable or not
@file ob.A:isDirectory=> hec1 directory or not
@file ob.A:length=> Display file si/e in byte
@file ob.A:is4idden=> hec1 hidden or not
@file ob.A:m1dir=> reate directory
@file ob.A:m1dirs=> reate any intervening parent
directory
@file ob.A:create7ew)ile=> reate files
6oid delete&n23it=> Delete the file
@file ob.A:set8ead&nly=> ,et file as read only mode
@file ob.A:set*ast-odified=@long
secA>
,ets the time stamp of invo1ing
ob.ect to that specified by sec
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
class file
B
public static void main=,tring argCD>throws 23ception
B
)ile =J4MVJava 7otesVJava $rogram lassVI&,treams
7otesVfile:.avaJ>E
get7ame= >
get$arent= >
e3ists= >
if)ile= >
isAbsolute= >
can8ead
can!rite
Delete= >
Is4idden= >
*ast-odified= >
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 10
"nt#od$ct%on to 5et*o#%n( !aca(e:
4CP="P:
Application
=400$<)0$<02*720>
0ransports
=0$< 5D$>
7etwor1
=I$<_>
*in1
=Device driver<::>
4CP:
0$ =0ransmission ontrol $rotocol> is a connection based protocol
that provides a reliable flow of data between two computers:
)DP:
5D$ is not connection \ based li1e 0$:
P#otocol:
A protocol is a rule or a complete set of rules defining how computers
communicate:
4y!es o& P#otocols:
1:Application $rotocol
2:0ransport $rotocol
3:7etwor1 $rotocol
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
).8 Classes:
58* is an acronym for 5niform 8esource *ocator and is a reference
=an address> to a resource on the internet
2(:
httpM IIwww:yahoo:com
httpM$rotocol Identifier:
IIwww:yahoo:com 8esource name
5sing pac1age import .ava:net:HE
5sing lasses 58* @ob. name A K new 58*=@!eb site nameA>E
58*onnection @ob. nameAK @5rl ob. nameA:openonnection=>E
)s%n( 1ethods 1ean%n(s
@ob. nameA:get$rotocol=>E Display the protocol name
@ob. nameA:get4ost=>E Display the 8esource name
@ob. nameA:get)ile=>E Display the )ile name
@ob. nameA:get$ort=>E Display the $ort number
@ob. nameA:get8ef=>E Display the 8eference name
2(:
II2g for 58* lass and methods
import .ava:net:HE
import .ava:io:HE
class url
B
public static void main=,tring argCD>throws 23ception
B
58* uKnew
58*=JhttpMII.ava:sun:comE'+Id+csIboo1sItutorialinto:htmlGD&!7*&A
DI79J>E
,ystem:out:println=J$rotocol isMJNu:get$rotocol=>>E
,ystem:out:println=J4ost isMJNu:get4ost=>>E
,ystem:out:println=J)ile name isMJNu:get)ile=>>E
,ystem:out:println=J$ort isMJNu:get$ort=>>E
,ystem:out:println=J8eference isMJNu:get8ef=>>E
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
F
).8Connect%on Classes:
2(:
II2g for 58*onnection lass and methods
import .ava:net:HE
import .ava:io:HE
class urlconnection
B
public static void main=,tring argCD>throws 23ception
B
58* uKnew 58*=JhttpMIIwww:yahoo:comJ>E
58*onnection ucK u:openonnection=>E
#uffered8eader bKnew #uffered8eader=uc:getInput,tream=>>E
,tring sE
while==sKb:read*ine=>>QKnull>
B
,ystem:out:println=s>E
F
F
F
"5et0dd#ess Classes:
"P0DD.2,,:
Ipaddress means 7et Address
,ynta- &o# &%nd the %!add#ess:
)s%n( Classes:
InetAddress:get*ocal4ost=>E
)s%n( 1ethods:
@ob. nameA:get4ost7ame=>II find computer name
@ob. nameA:get4ostAddress=>EIIfind computer ipaddress
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
import .ava:net:HE
import .ava:io:HE
class ipaddress
B
public static void main=,tring argCD>throws 23ception
B
InetAddress addrKInetAddress:get#y7ame=J*ocalhostJ>E
,ystem:out:println=JAddressMJNaddr>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 11
,ocet Classes:
A soc1et is one end point of a two?way communication lin1 between two
programs running on the networ1
A soc1et is bound to port number so that the 0$ *ayer can identify the
application that data is destined to be sent
7ormally a server runs on a specific computer and has a soc1et that is
bound to a specific port number: 0he server .ust waits< listening to the
soc1et for a client to ma1e a connection rePuest
,ynta- &o# ,ocet Class decla#at%on:
,oc1et @ob. nameA K new ,oc1et=>E
,ynta- &o# ,ocet 1ethods decla#at%on:
@ob. nameA:accept=>E II Accept the ,oc1et values
,e#ve#,ocet Classes:
,ynta- &o# ,e#ve#,ocet Class decla#at%on:
,erver,oc1et @&b. nameAKnew ,erver,oc1et=@port numberA>E
,ynta- &o# ,e#ve#,ocet 1ethods decla#at%on:
@ob. nameA:accept=>E II Accept the ,oc1et values
2(:
2( &o# ,e#ve# ,ocet
II2g for ,oc1et
import .ava:net:HE
import .ava:io:HE
class serversoc1et
B
public static void main=,tring arCD> throws 23ception
B
,oc1et sE
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,erver,oc1et ssKnew ,erver,oc1et=4+++>E
,ystem:out:println=J,erver is waitingJ>E
for=EE>
B
sKss:accept=>E
,ystem:out:println=Jport number isMJNs>E
,ystem:out:println=Jserver is onnectedJ>E
&utput,tream osKs:get&utput,tream=>E
$rint,tream psKnew $rint,tream=os>E
ps:println=J-essage from ,erver #,,VnJ>E
F
F
F
2(:
2( &o# Cl%ent ,ocet:
II2g for client soc1et
import .ava:net:HE
import .ava:io:HE
class clientsoc1et
B
public static void main=,tring arCD> throws 23ception
B
InetAddress addrKInetAddress:get#y7ame=JlocalhostJ>E
,oc1et sKnew ,oc1et=addr<4+++>E
,ystem:out:println=J,erver foundJ>E
,ystem:out:println=s>E
Input,tream isKs:getInput,tream=>E
DataInput,tream dK new DataInput,tream=is>E
,tring strKd:read*ine=>E
,ystem:out:println=str>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Data(#am,ocet Classes:
,ynta- &o# Data(#am,ocet Class decla#at%on:
Datagram,oc1et @ob. nameAKnew Datagram,oc1et=@port numberA>E
,ynta- &o# Data(#am,ocet 1ethods decla#at%on:
@ob. nameA:receive=@ob. nameA>E
Data(#amPacet Classes:
,ynta- &o# Data(#amPacet Class decla#at%on:
Datagram$ac1et @ob. nameAKnew Datagram$ac1et=b<b:length>E
,ynta- &o# Data(#amPacet 1ethods decla#at%on:
@ob. nameA:receive=@ob. nameA>E
2(:
2( &o# Data(#amPacet &o# ,e#ve#:
II2g for Datagram$ac1et for server:
import .ava:io:HE
import .ava:net:HE
class dps
B
public static void main=,tring arCD> throws 23ception
B
byte bCDKnew byteC1++DE
Datagram,oc1et dsKnew Datagram,oc1et=4+++>E
Datagram$ac1et dpKnew Datagram$ac1et=b<b:length>E
,ystem:out:println=J,erver is waitingJ>E
ds:receive=dp>E
bKdp:getData=>E
,tring strKnew ,tring=b>E
,ystem:out:println=str>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
2(:
2( &o# Data(#amPacet &o# Cl%ent:
II2g for Datagrampac1et for client
import .ava:net:HE
import .ava:io:HE
class dpc
B
public static void main=,tring arCD> throws 23ception
B
,tring strKJ4ello form #ssJE
byte bCDKnew byteCstr:length=>DE
bKstr:get#ytes=>E
InetAddress addrKInetAddress:get#y7ame=JlocalhostJ>E
Datagram,oc1et dsKnew Datagram,oc1et=>E
Datagram$ac1et dpKnew
Datagram$ac1et=b<b:length<addr<4+++>E
ds:send=dp>E
,ystem:out:println=J,ystem7ameMJNaddr>E
,ystem:out:println=JData sendJ>E
F
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 12
"nt#od$ct%on o& m$lt%th#ead%n(:
2-tends 4h#ead:
"m!lements 4h#ead:
Class: 13
'D<C B 'ava Data9ase Connect%v%ty
"nt#od$ct%on o& 'D<C:
Java Database onnectivity ='D<C> is a programming framewor1 for
Java developers writing programs that access information stored in
databases
What %s /D<CC
Database that another program lin1s to called a data source: -any data
sources< including products produced by -icrosoft and &racle< already
use a standard called &pen Database onnectivity =&D#>
Connect%on 9et*een 1s 0ccess to java *%th /D<C:
,te!: 1
reate the database table to -,A2,, for connecting the table
1, 0CC2,,:
,tart run -saccess =type> o1
,elect blan1 access database =,elect your directory> =db1> database
name `create`close the windows
,te!: 2
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,tart 8un control panel =type>o1 Administrator tools Data
,ource =&D#> user D,7Add -icrosoft access driver CH:mdbD
finish
Data source name 1arthi
lic1 select option`select the database name =db1:mdb>o1o1o1
2G:
1arthi
,te!: 3
5sing pac1age import .ava:sPl:HE
,ynta- &o# connect%on class decla#at%on:
lass:for7ame=Jsun:.dbc:odbc:Jdbc&dbcDriverJ>E
onnection @con
nameAKDriver-anager:getonnection=J.dbcModbcM@&D#nameAJ>E
,ynta- &o# statements class decla#at%on
,tatement @statement nameAK@con nameA:create,tatement=>E
8esult,et @result set nameAE
,ynta- &o# ,tatements 1ethods:
@statement nameA:e3ecute =@,^* statementsA>E used for create or
delete
@statement nameA:e3ecute^uery =@,^* statements A>E used for
select
@statement nameA:e3ecute5pdate=@,^* statements A>E used insert
or update
@statement nameA:commit=>E permanently store data
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
@statement nameA:roll#ac1=>E 5ndone the last data
@statement nameA:close=>E close statements
,ynta- &o# .es$lt,et 1ethods:
@resultset nameA:get,tring=@inde3A>E display string values
@resultset nameA:getInt= @inde3A>E display integer values
@resultset nameA:get)loat= @inde3A>E display float values
@resultset nameA:set,tring=@inde3A<@valueA>E set string values
@resultset nameA:setInt=@inde3A<@valueA>E set integer values
@resultset nameA:set)loat=@inde3A<@valueA>Eset float values:
@resultset nameA:ne3t= > chec1 the ne3t row
,te!: 4
,ave your .ava file
,te!: 5
ompile the Java program:
8un the .ava program
,ee the &utput
2(:
IIDatabase between Java to msaccess by using odbc control
import .ava:sPl:HE
class create
B
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
public static void main=,tring arCD>throws 23ception
B
lass:for7ame=Jsun:.dbc:odbc:Jdbc&dbcDriverJ>E
onnection
cnKDriver-anager:getonnection=J.dbcModbcM1arthiJ>E
,ystem:out:println=Jonnection is createdJ>E
,tatement stKcn:create,tatement=>E
,ystem:out:println=J,tatement is createdJ>E
,tring s1KJcreate table report=name te3t<designation
te3t<salary number>JE
st:e3ecute=s1>E
,ystem:out:println=J0able reated J>E
cn:commit=>E
st:close=>E
cn:close=>E
F
F
2(:
II0o insert into report database
import .ava:sPl:HE
class insert
B
public static void main=,tring argsCD> throws 23ception
B
lass:for7ame=Jsun:.dbc:odbc:Jdbc&dbcDriverJ>E
onnection cn K
Driver-anager:getonnection=J.dbcModbcM1arthiJ>E
,tatement st K cn:create,tatement=>E
st:e3ecute5pdate=Jinsert into report
values=L1arthiL<LAdminL<25+++>J>E
,ystem:out:println=J1 row createdJ>E
st:close=>E
cn:close=>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
F
F
2(:
II0o view all data from report
import .ava:sPl:HE
class select
B
public static void main=,tring argsCD>throws 23ception
B
lass:for7ame=Jsun:.dbc:odbc:Jdbc&dbcDriverJ>E
onnection cn K
Driver-anager:getonnection=J.dbcModbcM1arthiJ>E
,tatement st K cn:create,tatement=>E
8esult,et rsE
rs K st:e3ecute^uery=Jselect H from reportJ>E
,ystem:out:println=J7ameVtDesignationVt,alaryJ>E
while=rs:ne3t=>>
B
,ystem:out:print=rs:get,tring=1>NJVtJ>E
,ystem:out:print=rs:get,tring=2>NJVtJ>E
,ystem:out:println=rs:getInt=3>NJVtJ>E
F
,ystem:out:println=J2nd of recordJ>E
st:close=>E
cn:close=>E
F
F
2(:
II2g for delete all values from table
import .ava:sPl:HE
class delete
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
public static void main=,tring argsCD> throws 23ception
B
lass:for7ame=Jsun:.dbc:odbc:Jdbc&dbcDriverJ>E
onnection cn K
Driver-anager:getonnection=J.dbcModbcM1arthiJ>E
,tatement st K cn:create,tatement=>E
st:e3ecute5pdate=Jdelete H from reportJ>E
,ystem:out:println=JAll 8ecord deletedJ>E
cn:commit=>E
st:close=>E
cn:close=>E
F
F
2(:
II0o drop table from report data base
import .ava:sPl:HE
class drop
B
public static void main=,tring arCD>throws 23ception
B
lass:for7ame=Jsun:.dbc:odbc:Jdbc&dbcDriverJ>E
onnection
cnKDriver-anager:getonnection=J.dbcModbcM1arthiJ>E
,ystem:out:println=Jonnection is createdJ>E
,tatement stKcn:create,tatement=>E
,ystem:out:println=J,tatement is createdJ>E
st:e3ecute=Jdrop table reportJ>E
cn:commit=>E
,ystem:out:println=J0able droppedJ>E
st:close=>E
cn:close=>E
F
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
F
Class: 14
"nt#od$ct%on to 0!!let:
Applet is mainly used for create web pages
An applet is a dynamic interactive program that can run inside a web
page:
Displayed by a .ava capable such as hot .ava< 7etscape< &pera< -o/illa
)ire fo3< I:2 =Internet 23plorer>
0dvanta(e o& a!!let:
8un inside a .ava browser
Java applet has restricted to ensure security R prevent them from being
affected by the virus:
0!!let !aca(e:
import .ava: applet:HE
import .ava:awt:HE =Abstract windowing 0ool1it >
import .ava:awt:event:HE
8%&e cycle o& a!!let !#o(#amm%n(:
Init= > start= > stop= >
Com!%le#:
.avac @file nameA:.ava
.$n:
appletviewer @file nameA: Java
0!!let html ta(:
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
@applet code K @file nameA:class widthK@si/eA height K@si/eA
@IappletA
D%&&e#ence 9et*een Console 0!!l%cat%on and 0!!let 0!!l%cat%on:
Console 0!!l%cat%on 0!!let 0!!l%cat%on
onsole based 23ecution #rowser based 23ecution
23ecution begins from main
function
23ecution begins from init
function
5sing bac1ground and process
such as file handling data base
management system< etc
5sed for designing web pages
0here is no life cycle 0here is life cycle
Init= > start= > stop= >
destroy= >
0his type of method is called
on call bac1 method
,t#$ct$#e o& 0!!let !#o(#am:
II @omment lineA
@pac1ageA
public class @class nameA e3tends Applet
B
@variable declarationAE
public void init= >
B
@initiali/ation statementsAE
F
public void start= >
B
@starting statementsAE
F
public void paint= >
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
B
@ statementsAE
F
public void stop= >
B
@stop statementsAE
F
F
<as%c 0!!let !#o(#ams:
II0o display my name
import .ava:applet:HE
import .ava:awt:HE
public class p1 e3tends Applet
B
,tring sE
public void init=>
B
sKJ1arthi1eyanJE
F
public void paint=9raphics g>
B
g:draw,tring=s<25+<1++>E
F
F
II@applet codeKJp1:classJ widthK5++ heightK5++A @IappletA
Colo# Class:
,ynta- &o# colo# class:
olor @ob. nameA K new olor = >E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
&r
olor @ob. nameA K new olor =@color nameA>E
&r
olor @ob. nameA K new olor =@red int A< @green int A< @blue intA>E
1ethod &o# colo# classes:
set)oreground =olor @ob. nameA>E
set#ac1ground =olor @ob. nameA>E
setolor=olor @ob. nameA>E
5otes:
4ere set color is a graphics class method so we call the graphics ob.ect
,tanda#d colo#s:
Colo# name .(9 val$es
olor: !hite
255<255<255
olor: #lac1
+<+<+
olor: *ightgray
1(2<1(2<1(2
olor: 9ray 12'<12'<12'
olor: Dar1gray
"4<"4<"4
olor: 8ed
255<+<+
olor: 9reen
+<255<+
olor: #lue
+<+<255
olor: Xellow
255<255<+
olor: yan +<255<255
olor: -agenta 255<+<255
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
olor: $in1 255<1%5<1%5
olor: &range 255<2++<+
2(:
II2g for olor class
import .ava:applet:HE
import .ava:awt:HE
public class p2 e3tends Applet
B
public olor bKnew olor=255<255<+>E
public olor fKnew olor=+<+<255>E
public void init=>
B
set)oreground=f>E
set#ac1ground=b>E
F
public void paint=9raphics g>
B
g:draw,tring=J1arthi1eyanJ<25+<1++>E
g:setolor=olor:orange>E
g:draw,tring=JKKKKKKKKKKKJ<25+<12+>E
F
F
II@applet codeKJp2:classJ widthK5++ heightK5++A @IappletA
+ont Class:
,ynta- &o# &ont class:
)ont @ob. nameA K new )ont =@nameA< @styleA< @si/eA>E
1ethods &o# &ont classes:
set)ont @ob. nameAE II0o apply font
@e#e:
set)ont also one of the graphics method:
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ome &ont name:
2G:
0imes 7ew 8oman
-onotype orsiva
,tyle:
)ont: #&*D
)ont: I0A*I
)ont: $*AI7
2(:
II2g for )ont class
import .ava:applet:HE
import .ava:awt:HE
public class p3 e3tends Applet
B
public olor bKnew olor=255<255<+>E
public olor fKnew olor=+<+<255>E
public )ont ffKnew )ont=J-onotype orsivaJ<)ont:#&*D<2">E
public void init=>
B
set)oreground=f>E
set#ac1ground=b>E
F
public void paint=9raphics g>
B
g:set)ont=ff>E
g:draw,tring=J1arthi1eyanJ<25+<1++>E
g:setolor=olor:orange>E
g:draw,tring=JKKKKKKKKJ<25+<12+>E
F
F
II@applet codeKJp3:classJ widthK5++ heightK5++A @IappletA
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 15
"nt#od$ct%on to G#a!h%cs:
8%ne method:
0o draw a straight lines
,ynta- &o# d#a*l%ne method:
@graphics ob. nameA:drawline= @int 31A<@int y1A<@int 32A<@int y2A>E
2(:
II2g for draw*ine method
import .ava:applet:HE
import .ava:awt:HE
public class p4 e3tends Applet
B
public olor fK new olor=255<+<+>E
public olor bK new olor=+<255<+>E
public void init=>
B
set)oreground=f>E
set#ac1ground=b>E
F
public void paint=9raphics g>
B
g:draw,tring=Jmy homeJ<%5+<3++>E
g:draw,tring=JKKKKKKKJ<%5+<32+>E
g:draw*ine=3++<2++<'++<2++>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
int iK+E
while=i@K4"+>
B
g:draw*ine=3++Ni<2++<1++Ni<4++>E
iKiN4+E
F
g:draw*ine='++<2++<"++<4++>E
g:draw*ine=1++<4++<(++<4++>E
g:draw*ine='++<2++<(++<4++>E
g:draw*ine=11+<4++<11+<"++>E
g:draw*ine="1+<4++<"1+<"++>E
g:draw*ine='(+<4++<'(+<"++>E
g:draw*ine=11+<"++<'(+<"++>E
F
F
II@applet codeKJp4:classJ heightK'++ widthK1+++A @IappletA
.ectan(le method:
.ectan(le:
0hey are 3 1inds of rectangles:
1> $lain 8ectangle
2> 8ound 8ectangle
3> 3?Dimensional 8ectangle
2ach o& these .ectan(les has 2 methods:
Draw the 8ectangle in outline color
Draw the 8ectangle in )illed with color
17 Pla%n .ectan(le:
5sed to draw a 7ormal 8ectangle
,ynta- &o# d#a*#ect method:
@grap ob. nameA: draw8ect =@int leftA< @int topA<@int widthA< @int
heightA>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
,ynta- &o# &%ll#ect method:
@grap ob. nameA: fill8ect =@int leftA< @int topA<@int widthA< @int
heightA>E
2(:
II2g for draw8ect method
import .ava:applet:HE
import .ava:awt:HE
public class p5 e3tends Applet
B
public olor fK new olor=+<+<255>E
public olor bK new olor=+<255<+>E
public void init=>
B
set)oreground=f>E
set#ac1ground=b>E
F
public void paint=9raphics g>
B
g:setolor=olor:red>E
g:fill8ect=2++<2++<5++<4++>E
g:setolor=olor:blac1>E
g:fill8ect=22+<22+<4"+<3"+>E
g:setolor=olor:red>E
g:draw8ect=4++<"++<1++<1++>E
g:fill8ect=3++<%++<3++<5+>E
g:setolor=olor:white>E
g:draw,tring=J#*A; #&A8DJ<4++<4++>E
F
F
II@applet codeKJp5:classJ heightK'++ widthK1+++A @IappletA
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
27 .o$nd .ectan(le:
5sed to draw a 8ound rectangle
,ynta- &o# d#a* #o$nd #ect method:
@grap ob. nameA: draw8ound8ect =@int leftA< @int topA<@int widthA<
@int heightA<@left bendA< @right bendA>E
,ynta- &o# &%ll #o$nd #ect method:
@grap ob. nameA: fill8ound8ect =@int leftA< @int topA<@int widthA<
@int heightAA<@left bendA< @right bendA>E
2(:
II2g for draw8ound8ectangle method
import .ava:applet:HE
import .ava:awt:HE
public class p" e3tends Applet
B
public olor fK new olor=+<+<255>E
public olor bK new olor=+<255<+>E
public void init=>
B
set)oreground=f>E
set#ac1ground=b>E
F
public void paint=9raphics g>
B
int .K5E
g:setolor=olor:red>E
while=.@K3++>
B
g:draw8ound8ect=5++?.<3(5?.<1+N.N.<1+N.N.<1+N.N.<1+N.N.>E
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
.K.N5E
F
F
F
II@applet codeKJp":classJ heightK'++ widthK1+++A @IappletA
37 3d .ectan(le:
5sed to draw a 3Drectangle
,ynta- &o# d#a* 3d #ectan(le method:
@grap ob. nameA: draw3D8ect =@int leftA< @int topA< @int widthA<
@int heightA< @true I falseA>E
,ynta- &o# &%ll 3Bd#ectan(le method:
@grap ob. nameA: fill3D8ect =@int leftA< @int topA< @int widthA< @int
heightA< @true I falseA>E
2(:
II2g for 3D8ect method
import .ava:applet:HE
import .ava:awt:HE
public class p% e3tends Applet
B
public olor fK new olor=+<+<255>E
public olor bK new olor=+<255<+>E
public void init=>
B
set)oreground=f>E
set#ac1ground=b>E
F
public void paint=9raphics g>
B
g:fill3D8ect=1++<1++<4++<2++<true>E
g:draw3D8ect=4++<4++<4++<2++<false>E
F
F
II@applet codeKJp%:classJ heightK'++ widthK1+++A @IappletA
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
Class: 16
$olygon method
&val method
Arc method
Image classes
Class: 17
Introduction to A!0 components
*abel lass
0e3t )ield lass
#utton lass
$anel lass
Class: 18
Introduction to 2vents
-ouse 2vents
;eyboard 2vents
Item 2vents
Class: 19
0e3t Area lass
,crollbar lass
hec1bo3 lass
hec1bo3 9roup lass
Class: 20
hoice lass
*ist lass
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
)rame lass
-ouse ursor lass
Class: 21
-enu bar lass
$opup -enu lass
anvas lass
Class: 22
Introduction of *ayout
)low*ayout lass
9rid*ayout lass
#order*ayout lass
ard*ayout lass
Class: 23
Introduction to swings
,wings ontrols or omponents
,wings !indows
,wings $rograms
Class: 24
-essage bo3
0imer lass
$rogress#ar lass
Dialog lass
Class: 25
,wings -enus lass
,wings ontainer
,wings $rograms
THANKING YOU
CREATED BY A.KARTHIKEYAN
COMPLETE JAVA NOTES
THANKING YOU
CREATED BY A.KARTHIKEYAN

Das könnte Ihnen auch gefallen