0% found this document useful (0 votes)
7 views

Java Notes 2

Uploaded by

Ashu jadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Java Notes 2

Uploaded by

Ashu jadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

* Acaption Honding

Clogs Test

int o 100 b 0

whenever dhee is emeep'on he mettod in which


encepon ocosg l4 coeqte n objeet f that objet w)

desoniption

Dbjeet
Reepion QoBe
deseriptio) onuadly hondle
stoek tso ce
coteh
hond ter inay
Pojot

demtnates nomally
the aldergn ate woy to eoNR the eeepHD
Noma Terninadion
20md by
ovda od
zem :/byPceptton Anthmait long jouo.
ro) dividle connot
by s$O"
you syso(e);
|
Ssysolj
20,2 b00, ae nt
Test clagg
ute ee otll
toy in
tin emeepion istheme
la<k 2oteh ode hanolir I/
loseName CAoeptlon coteh
nome)rotvo.
tode isky Il
oxeeste block (Aay
olooys)
syrlo
cadeh fHry
Ooy to cosite hande code Oe stotk priStock
doss TRst o) Sop2), Sop(e.tos

22 o/6
,Syso (e
cutehcArrithmatzExeepion e)
e printstoek rae (
(O:) o r
osld dshos Syso (e) syso (e to strngc); some
Syso (e.gedmesayel

DPy tawa, long Arl thmadHebmeglion: by zem

aNO, lay Aithmaeraepdig byby ze


by zeno

Hnoh lozk con not eyeeu


System. Qaid c) me4hod

death ot thoneod
se-> Conneetion lose(Oadabore
Logneleose eleoge

Ainally finally s the bloek thad i adwoy RXecaite


whetthe eneepdion is hondled os not.

rfnaly
9mrsligeos
CAhally Slock will epe wte oldys)
fd Co

use nultiplecoteh ble cky with dy 6loct but


s)ngle tinas ly block wth ane try boct

I omtnaly s'ock
lorz,Anthmeor

bobroe
Anaily
noh201
eNLPAio.l
User detne
Hod to thao <lossNome Eareption msq}
thoow
s blds ddedt

thou ned Eyee ptlon Closflome "


das Test
atw olgo poSsible
llosStt
Loatuse ta usendedined
eeptir
oo

YounghgeGysepia) egetenols Runtimebeephon


class
Yoong enAqe Rsception Cstsiy smsg)
&uper Cms);

on

Z)
thro ned
2
noh ellible)
Unchecked eceAeo Y
ehezked 0
o we con hooa ejthen
bnly dhnw loss th ad comes in thooebe ehJ
we
osite ony stotemeot ater tho Dhernse
We connoft errs
jt psouide vnregchable stetemet

hous eywo s used to deelome eoceptio).


thene
Ih gheg ar jomaton to the eadle method that method
ur an erception so it s better tos the ale
to pnude tte eeption hondling eode so tho noma flo
be maltaned

fontend (usprin Bocken d base


Contole
(rolut
SemieeS84

Hibemate

Aoooylist Lin
Ale tondling rlte dodo
deAiney how e on oeac al the
* Ale hondling soNg o pozkage contan
dasses
Dn o
a Ale output
input
thoough whleh e ton perttoy a
opemattony în tthe file
seguen ce ot dado, on the baais at
stream is dedainto 2streo
elagses
jaNdO poekge al) Ahe
the a9se

horeten

¢ Pile Hondting Methods :


on Read <) G) qetAbsalutepethc)
List )
) 0elete cy Reod)

lengdth )
* le Hondry elossey

fle Qutputttregm
) ButeTrputttromn
AtenrOuteutstmegn
Operractton_n le
Coeate Ale
intormatto
getfile

Ale f ne Ale<users lenavo Moes ktopl\ Penôto

Sys0 Ae creade sueues idolty);

9219

Alelaelte foa ne Alethiter Pacth');


is Aed"';

Resd oado in tle


* Apgend in Ale
fleiter ( poth, tre
Aletiter t e ne
Aowite(" welome to J6k)i

clocs AleMethods
throu TOLepto
Nojd oreateAileMethod (string patb)
pile f new Aile(patth;

Syso(fle is already teated')

lse
Acreade NeudfiK}
Syso' Ale scoeated sULSRL1dulb

Nold JitheDeto (string poth tring tine)throws TOBKepton

Aleaider tws new Alewatte(Path)


tel sie tioe)'
Alewite tusane Aleite(padh, tue)}
Au ìheltine);hsl
oRpend ito Ale");
tu elage()

Padh)

int i

syso ((zhor)i)

2bsta

Alemethools s$nes lermethode (Od


2'N Users Admintn Desktop f14 HondtyDmo
n
eadDato my nome Boct
Aadinatt
oumkordhud
Oiftenenee betseen
Hoshset, Treefet Lin ked Hoghseh
Tieelet Lin leed tahlat
HoshSet brterd
ertendy toshseh
Ertenods Abstrochsef O fendo gbstottetelors,
) Tnplements, Novigable
closs
Oset, zlanable seilable ) Tmplemere
Non-syrchronise chenable senial
clonable reillzabe I- jodertoe
Nonsynchronlse
to add Juptieoty
inse rtlon orderHwill
licady)duplisdes vadve
not allbw do ad dop malton inetior,
Treelet ntemaly
Hostset ioteenaly oreate CseoteTrieetbp
Hoshset irtenaly (reoy
Ho hmoup CiCrodsi inked bsh ap

Hoshngp. OBatends Abstsoehap


inplemert map OtamplementAoigable pmap
clonokle, semlbase h seileeble inteoce
Jonaste
indentoee Treenap 2onten yaJue baved
e) eten dg Abstoozttnapb
Hotnopi 2otales Noluegn the keyi antho key
Taee mop iJaTted by ket
hae'
single S Tt lonnot haye o pu key
but haye mutple nu ale
Hachnap dos nt modain onde ascendiy olem
cAhile iherraty
cootain urlgueelemet
Hoshmap is toster ompom to
4osh map
Treemap
The Hashmapeloss usey iokrnally
Redblok tree
e hosh table
Trgutstreomfoutgutsteom

Hasktable
Hashtae synchryniseo
O Hochtable is
Hoshma is ron gynchsed.
ttoshtable doesnd atled ary
Hoshmop_a los one nul key
valees. nellke o Nalue,
¢ meHple null
slo
fost Harbtasle inhend o)tooy
Hoshenap inhet Atboodnap elas Ja.

Linked Hosh op. xdend tojh


tte voue n te pete key-por 0mbincor.
I4 stor
dupticots elementi
TA con not hove myple null vahey
a T moy hove 6ne nu"
nu" key
key 8
Tt ii nsn- Syrehrsed
proujdey
lolleloaC
Colleeti on
on iotetoze
element
O To ercsent group ot
bperate on coleeton.
L9lleeten (ike Sort,seoh mìn m
(Oeence
steingbu ter Sring,Butde
Strirg sAsthy Bufter is a
Stsln is oimmutask muteble loss jn
clase nal class they
It is Some
jmplement ehomgedwenceobava
serilizabte, compongauble Strlng lo9!
thseadsabe,
indertoee megns dun thad
str'y objeet stre thneedsade

nged.e threadsade.
Sp memey
I¢ we ekonealae Tt meons tuo thread Simuienash
Lontt cad de etteds ) sliy Builderi

toneousy thon stimButhen


syehonsed elos
hetuhy he is ot strln Buter is less
thneo sate atdent Ahon stty Buldea
stsiy Butyer obheet tord
slo Sholyt Zongumey leif
hemoy

to mybatten
Comeile Hme eyeepMen
Ru4}me en2ep46r one the
O
. omplle me eRepton meony eAeeptery that or not eheo
whieh one
those eeepanN
zheek by ompiler ad compiledime
ehebe pragrom
In compìl e e eneepa 20mpilRs ne beeouse the
prrqrom Qveg omplloaione
Aametho thooe
Ahe2eponE
methed
st Some cade costhin uneheeked eeeptons ges
thouk ehesked eaeeptlo) tte
mogdly due do prgromy
the method mt ther handle mìstokes
peelty
the epeepttoq cot muet They are re subdage

te ehonees otfaûlwn to hh
ohen
They but do nt
nhenhom unttmeenzeph das
At core Jovo Notey
Oith s poirt on e0eh topie

O fova proqammtng lonquage.


puspose highlenel stadic comeiled
O Tovo is a qeneral
prngrommin longuage
Jovo is sinple progromjy longuage bezguse jovo is Nary
eosy to Ieom o simple' understondabe Jongusqe s udls
osjovo complieated teotuney like operadon
ONessloadiy pointer ¢ Ht syntor deperd og tt.
ToNo is obËeet oriented pmqtomiy longuoye beeouse, o
Jovo Nenj thing is on dbject bËeat ósientedmeone
ongoniie
that iDcasporsate beth dato behoviour, jovg ineludee
oops (oncept like poymosphigm oubstsortton enp iobende:
longuae
Jovo is o plattonm independonh rogrom)ry longvare
becousejano (ompìler compìle tte seumeeode f cosNet i
into bythe 2odethat byte ladecon be un n mutt) p'e
platdoms ike iadouls, Molo, Bnus
JaNO is oobust qrog 1omin loyue then jong is orehiheeha
netasal longuaje mgliahneaded 7 Seeune ete
Nasables
memos (ocatton
Nosable is ike cooteÓer dhih is used to stene dete

de
eloratof iot oa16 dedinidion
) dototpe
To aeprese d ata in memor de
We con Use dedodype
To gRpresert dyee ot o Nonable e eo9 use datote.
dato tyee dedeg the memory
datope dede the onge ot Nalde Jhih ose store
datodpe
io vonable,
joNa, primitue Non pojmive
T0o type ot ooable jo hom booteon shost 1eng these these ore
double
A drs c înt, byhe, tHoad, eloss ee these ore pon-m
poinitve dototpej. Anoy story
Aloot byte, odouble lory to &
a iot sequlred 4byhe memor
aint
byte t r buoleon bit t r short
tur ehon o byde, ter bte
ebrte ot byte short lory dado by pes detout Nolwe is o
Aloat f dovble detoult olue i ehor t bolesqpdfoleh
(Rores- iotnbtoeb

DktRR, TY
rt is used do develop, modihy jong opoliatis

TRA t is vsed to eeute jona pplicadon .


1onpiler gt is used to he t syp otoNg pogro
-) onNRS Souree code ioto byte eode
SM gt js Used to proulde geso uney i ke memo dlsceton aJlbcehe
t intespstter conNents byte ode jato Mochne 2ode!
->it l sed te erewte byde eode

Opers adorg
O pesador /s Syobol tha is used to pestorm opesd}ons
to user oguioe ments
oine eoly dyee ot opersodo.
GAsithmatte Reladonal 1ogicadl
logeeal Aeslgnme Onosy Aumory
Amithendie opertos ann wse cto penttomm omithiadte
dpssstiagy ike AdlitHon sabthrocHo mwttiplfischoh
Relattano Hl ang used to check dhe meladanship betleen

ogic opersatrs ome Used to eheek


0r talke. Thery ore
They
Ale one Used do aoaBgn Nahte to ariable!.

opeoco thot otts on o


sIngle openond is (otled unog 0perroter
postll meo) att prelyn tto

ß block ot code booedresult ot condlt)..


Contaol to sfadenent
Cand H
tonel stotement
then
s dont change dthe tlaid et my proqsom eecstio) tte
(onto Alow stode ment.
qoing to use conto
3 types ot conto Aloo stotemett
Thesa Ne oonster stedemert
TA I Dot eAReute So me blaek o code on the boss o
Condi ond gult ten T am qoBo to use condiAona stade
I DoFt to epet some Elok o Lode 9 the basj
ot condAog elf

If TArelse
It-else-ib-else
Sope block ot code on he bosis
ot condiog eult tteyS om qoy It stedemert
I Wont to eeeute sme blok &A tatemernt on the

wilbe erxeeute it tondion GAolse ten else bleek a


T s Oont do eseeute Some bloek

else~it bo eheek
block o)1l eeute
lseit blok tolse Hen eJse
whle Jop.
S) foslop, wkile do on the bosig oteondih
epeat some blozk ot ode
AT s dontto
goly t ue for lop
om
code otleat one w)thut
ot
ent oto enRcute ssme bjozk

derninate te my leop the Tom bresk

qory do Use eontinu

( Class
6 doss j d tenp lade os bluepiot Arom heh ob)« ore
Joss is

Uosss Îs goup ot obËet c hich hoNe (ommo) prperhy

Jass
Jass deenine hcud objeet behoe cohich objech lt ceotern
ohject
cbËeet it on inghonce ot o dors.
phy ical ati.
dbjech oeguirsdonmemsg
et,ch hane stedey Lhel beh aye
Dt data metthods.

dthere
keybord by usly ned insone medhod clas,
by uslrg neD method ot oneator clost
by usl ne inotonce
usy elone meth od ) by woly desen 2tis)
by
() Referene Yonì able,
coecon uie
TO aeees_tunton allt ot on objeet
Tt ol hold eterence ot on obj'eet

Retusdype
alie is caled etun tyoe
datoype ot tte etun laue
returtpe
fuesz oethod inn oNg is dedoed ith o
A netumpe moy be o pri nite Aye like int tead
ouble eteence type
be
The type ot dato etumed bya method must
compltable with tte metum type speided by method
The etum tyee meguired un teement et te
end ot te method

Con tncthor

Jnstonee o)abke
foo eoch objeet 2ogtruetr Ot! eyeeute on ce
congteder method Which awe not ary don
dyee nehoiy Noid.
G) Ohen coe ereate an object ontveter 0!! wtomette

not be fin oabstro et stecte


0e hod2 public, prHvete prodeedegdetout
() This keycoord
to the Cument doss jndtence
that rote
athis is o keyO0rd
(membej
oryhere eneept stete blozkfpsttte
ure Ais keyword in
we con use h i
medhod
Qecon vse i kepeOoTe o ot dmes,
end s Used cer ditteretiete betdee) global tonabe
this keyo
f bcaNori able

Supes keylord
keyQord thect ter to the super dag insfonee
Super is o
membes
super key Qo holds he otormatiog ot Super eloes.
Super keyL0 osd is used tye ohAterentiate betee) superelosf
nstonce menbeng subelass nsfon (e nember.
USe supeskezsoend inde stet'e bfotefmetheo.
GtatetQUper ie non-stedi na etereeoable.

T5is eall¢ sypereall


T5iS cadl¢ sUpere) both one constueten co), thìtcal) is used

Se

e co9 Ve both ca ide tte conrt tine

((9) bloek
Time con tumny cde e eon Oit nde te b<at

shotie stock dests wth Jay f nttonee block deals artd obse
tonee oek ao ecte Shen
(20
clocs hedore 2onstetow eetwtfon stetie vomae
Jnstde otadie Sock cde co) alvels cnly
(inside jnstonee blotk de toF oceelf Intonee I static Yon
black
ty Botk exeute alajs.
i
A theme is expeetBop ocewm in ty block tte codh block Oy!

cde con conide encepttogn hondly code ia 2adeh biek


Sfinally blsek execate albay her etreptlog ocum or
De con cosite

thro ether che zlked or uncheeked xgeatte.


throug key oond g?424 tte antomatton to callen pethed tha
ttere mry oceus
te caller methnd o pnuide enceptoq fhondiy code.
ctor tte madnten nomal leud ot progoom
fecess spe ltiers
We hone 4 druess modiegO public Ophvode @pohetee
Shere De

n) pokaye imporch
O pockaye s oo slmple tolder
poskge js cotlezthy
colleztiog ot Wosreyfototoce
wotsey
ANeyy elasf f inttaoe the part atpoekre,
out be pockye stetemeqd
njonoprogrom frst tattmegt
pockae statemeF+
pe coq orik atmest one asl Jossess,itotoo
to mport
import kay coamd te used
-le fpockagA
model thod pooujd
objeet.oriente pDgnomminy is ainhestene bsfrgtio
dith de ey ot concepdye
pblg morphism ecapsuladta9 thege
ente
cbetorient prognomm)y is o methodolog to desiqn o
Q alosseg objeedt. smp lidses sothaar
prograrn usly manonohee by_prouldy some cancepts
JeNelepment f
Bke objeet closs

Tnhertenee,
O The process Ohere one elogf agure cal! propetey metho
of another elq9! calle oheitence,
Joyg Suppont sngle multilere/ p terenhie iohentenee ay

O ToNe suppoxt mutiele f bybng ohestenee by usty nterfoces.


Thee are Gypes o oheHdence

eColle ct?og,colleetion foomeDorrk folle ctiont


APr Jhich contain predetinad

callactioq is theiateto ee Ceresert jn Jova ut poekye).


rolleetion 6bje et
c9lleettons is
js dthe utili,. 9hi eh carrtedn ooly stet eth
efrsatcoming macy ede
a List Totertoce,
mutable orfdered hetemogeriouj calletteg
Ohere duplicatiog ie aJloof jntértlag onsen
element
299 be preseNe
by vey ge methodr
De con get I elermentt
ton get at elemets by ady iterecon
list is jndy bose dato stuetume vauey.
Nmber et nu

SE7 tetoce
nutabje unordered heteregenja callettoq
ot elemends ohene dupticodtop is oot allod $inseran
onder yn not be preseNed
) Se stre dato yeao diy o the hoshcade yaluey.
Set con stre on
con qet set elemert voy iteraden

enty A map costedn unjgNe kery.


A hap seu jt yel hae d seaeh ved ade,
alel ete element on the bar o key.
Jlosed't adjow oupliate kazs but y l con have
duplieote yalues,
Soted IAP extends ap iotutoee
Stesh soiop Ëmplemett ae jndertec
Linked hah na
The mep tudace heude medhods thy dme put get
Lkey ateng alwe
Arroylizt
pruent in ja util pock.
SWeh j
eetenols fbstootlist wos!.
Arroy list elors. Notthreaclsat )
rroylit is not ynebronired
tte bati of grlable fresjzable frrg
Arroylis cmeateg onditteet dpes et dato
Arosy list con stere duplicate yalueg.
3Arroylist con gtore order.
frroylit follo usjnsenatte)data sfrNetune
Gfrrlist ore jndeg bored n otinuos memey locatin
Aroylist stere tte elernegt
10

Linked ligt Jheh


lass f ist iottoe
o LËnkeaitt is 0NU an inplemeotee
is present UAl po4kye
eytnds AbsfroetRA'does
Linkedlrt chroaeeg dos Cnottoacsalsafe )
Lnked list is nod-syn lioked lis is dowbly linked tif
The undenline detosfutue o of dato ¢ duplicate valves,
pes
I mkeallat co9 store ditt
Lunkedlit tolfad jnsktion orden
stere te clement n nodes.
línkediBt
coleetag ot fuo sub elenes rport
tode’ Aoodk
Node
o th net node prsent n te order
eoh ode pens insettsn deleto seerediag,
Aos! oked lis t j qod cfer
aked megujoo
(a) ye etor
Neetr fs inplemented
present in jo0,ut| poekeeeloss.Cthrad safe)
teetr fo ynehroniced
also,
pg datof duplkate Ngdsey
Neeter L9n stone ditt
Neztr Allas
stuetun
eer fndeg boe dat

yeetris_qod for retisad 6perratio.

nplemety lass Set iatotac ieh


O Hashset
atashset is non~yzhrosed elast
tHoshiet enfends Abstrgettet yar.
Hoshset con gtore ol itteeot typey ot afu but jt cant
sstre auplleote Naduer.(e9n sto onl o9e ull yade
9 Hashset dosent to lod insenio) orde
ttoshyet iotunelly reaty hashmop.

3)Tree Set
Treeset mpleme stko do of Nagigeble set donolk

Taeejet eatends fbstoetset eay


cuplicade Jaer,
are one storeg n sontee nly onlern
objeet

You might also like