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

X - Ch.2 - Library Classes - Notes

Uploaded by

premaprema3177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

X - Ch.2 - Library Classes - Notes

Uploaded by

premaprema3177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

1 JDK Java Derelopmont Kit

Incudlesal pex Aoltone


ook which an Bssanial
needad whil wuing p709aMa.
maja Component JDK
Jowa Clas rap (JCL)
Hhat contoins vasúnus packoges

2 JCL Javo Class Gbna


Java Clays Lilbnant conbaina
Vauous ackog3
Each packaqe q JCL iS a

colleclion. clasges& containing


olilleunt ouilk-in junclions.
3 Lmponant package uhich a

Java ackages Puypoe


javalona ContoinsclassesPalabe l
lung- maipulaliong
Con taunsA Claszes Or
input oukput opehakos
aNa uwt Containa clases lo implomunt
Graphial Uher Inkonlaa (GUT)
ava uli Contains u , _claes
implemenl_ daka ucune
oya applet Lonkausclasseso
implamenlingr appela.
Oa net Contauu classes sen Appotling
helusotK operalio
ala ma Contains clanes or
malhenalica hestalions
2

he Kuywcnc imports
import
used includea mckap
in aJao prqam

Syolox
import packoge name R3
Example
impont jana u *
to - Scann
import jowa
he aLwúnK *)Aign
incicalis bhat all
classes the 1mponked
pacKag Con e
weolin
the phoaom
Wle a pecilieclas

we lass nome in

ploca
java: long packoge s
impotked y olefaulk

5 Prinai ivedoka type


Funolomental or Baic
dolo res
Cnaled ta Ayiu
daveloparu
Designeol dacahe
Vasialt thak con a

Singa elamaxt - rumber O


chorocla
Exanph int
leak
oloulle
chasr ek
Deinaa .
Lompoiliolaa bup Primitive dala pe is
Cor) notAuiienk Iondl
Non-paimiEive Compla opealion
dalo typ In Auch Aitualions
(OT) cup imilan On
Kelenenca olata type dalont phimibive ypa
(or) may e incudhd
Uer deinac ExomplO
olaa pe Amo
A Componile dala
pe tat wes

Aimilophimite
olala tnes
-Exampl
Clas
Whan class s
olefinadL iE becomus
a olaa e
Containsa numbe
pimilive daka
ynes
Clas name (an
Le seo o
olaelau anu
Vaxiale callod
oljeck
Dieunca
PimiliveDla Type Lompo Dako lype

FunchmankalBasc Dala ype :Tisa set q Thimilue


olalatype
2 Dapoad by the Syslan
2 Debrad b tha
dorelopass
A

g. Almppen lass A ilt-in daa type thak


s CompoNlC în nakww.

A post
part Jawa ibrasu
packageJau-Xono ono
clas Hhak contains a
Is a
phimilive olako
Whan oljact isCaod tor
wopperclaxs a

memonY is allocarad l
Conkain o phimilive daa

DHe puue values


Need ang
in Bheoljecl
WrappanCas
loConweut a tino
oota inlo othepsinikive
p e sa n d Hce-veLa

Ex nteaen Xa_now Tntasen (25) j

8Wrappeh ClasAes Primiiveala lyp


Chotacoh cha
By
Shonk Ahont
Inbeaeh int
Lona Xonor
Fleo lpo
Doule olauble
Boolon boolaon
-stoous with umer co storbs with
ouse Caye
Methods q WroppenClosxes

Nuneuic Dala

Tnbager
is auwToppe clas that contains
primiiwe_alala byne int.
hunclions o Tnleae class
0

Inleqepasselnt ) To conNteht Aing inlo


Lnleaon- valuaC)J inlage dala pe

InaoloStirg ) lo Corwenk an
inkger dala
bype inlb abin9-

Ex 1: osiato n
Sbing s= 24 wwlz in
int n ntagen: pahueInt(s) 3
24 uieou
(oT)
uo
ine n= Dnkegen-ValunQ(s)
An inua ipe
Ex 2: inn-24 gels conterto ta
Shino, STnleqpnSing-(n) ; Sbino

on
uncionA
Sin S=123456
onapatuelonaL)
(Or)
Lono n=Long- pauselLono.S)
Lonay Vnua.Q t PLona n Long valued (s)
Long a Sbn,) Lono na 123456
Sbing S =

Lona bdling (n);


Floak

hunclions
Seing s'12-34
Flook-paseFloato Floot n Floak potse-loot[s);
Flool-valua ) (OT) loal na Floak. valuQ (s)

loat n- 12 343
Floak- l6Shing t) Slhing s-Flot-b Sting (n);

Doule
Funciona
Sling S 1284567189
Doulle:paeDoule ) 1 doul ol- Doulbl-pahueDoulh (s)y
DoultevnluuQ cor) doult d- Doub valucs)
doula n-
12-345b T89,
Deab lbSbing) Sbina s Doubte: l6Sbing cn);
0
Characli A Lelto a digit au
Apeial ymbaencloed wibun
Sinolouobs s oainael
chahaca
Erampl

Assioning value:

Synlax< charadih dala type s vosialta = < chasala leraly

Exampla chan chi='A


choa chz6
chos chat
Lnpuk a chatacli: Using Sonnus Clasa

Sylox:kchany <voaialtey <Scanne olbjecky. nak)-chanAl-to)

Example chax dha in-nark-


chasAtto)
Using Inpul:SkreamRaads las
Syakox kchoay <vatialblay- lchan) <bufoudkaado adijeck)-huoc.
Exomph chos cha tchas Jin hiadu)
Functons

)Chaoclis.islatia0 Lseed check huhen th


gven ahqunutValue IS
Nt on no.
Reluans boohan Iut or ale

Synlas boolan KvanyChasacls-islelalchanacla)

Example boohan b- chaaactin-i Luten.()3


heluang Ehue
boolkan b- Chasaclä-uLelter.CB);
-helus alse

2) Chanacl-is Digik) had lchuck whulher th


9uen 0nqunant a Digit
not

Raliens boolean

boolan Chaocla is Diqt (chanacoa)


Su <vasy

Exampl: bolaan bChaaca-i, Digik (C)


neluns false
beolaan bChanacla-iDigie('3') 3

aChohocin.isLetenOnDiqik )
lsed ls chack uutkan ta
OAen agmnE s eithua
a
Kolins boolaan
Synkax boohan 4van> - Chanacln.ietn OnDigit (chaaacli);

Exampl:bealon b- Chaacln.iuletnOnDigit('e');
- Kalusus u
boolsan b-Chahadin.üLotaOnDrait(3);
Rains bu
boolaan b- ChanaclisületiaD.Digi ('*')
-Reuns ale

A)Chahaclia:iuWhilkspacal)
-lsed lo chck whether thaq
anqument is a wia p a c (blank)
Leo chuce or ling
an eis
blank oh gap in_a Sing
Rus booloan

Synlax:boolaon <van =Characlas is Whiläspoce ( characla)3

Exomple:beolas Chataclan ísWlilispace );


-Relunnsrue
boolaon ba Charoclin-is Wlaispoca ('*') 3
-Rins abe.
5)Chanoci illpperlasel)
'-e ls chuck uatker th guen
OgumerUE Ig on wppehoje
Rlisus boolaan.

Synox: boolaan voty- Charocoi..is Uppealase tchaac);


Exampla: boolan b-Characa-üllppalase CC);_
- Rauare uL
beolaan b Chabeck.i Uppanase ('e);
Ranans ala.
Phge No-

) Chasacn-üLoulenoe )
llsed s_ckeck whelhor the guen
araunmant ualouwercase ltton
RTensboolaan
Synla boolaan <vas =Characha isLowenlase (characlor),

Eample:boolaor. ba Chatacis iuLoueaane('c');


-Raiwuns ale
boolaan bChanacla iuouealase('c')
Raisns
1)Characwhlblppanlare)
11RBs en en anoLuyl in
uppencaw chonacas
Giuen chahaca hmaL Aam
it is alradu i n ubpencoAe
Rlurns Aamachasaclo
he given characlb is nota oiar.

Synlax cha vahy =Chaada.lo opeaase (choracda)

Exayple: chon ba Chatoco lolpperlae("a');_


RlisnsA
chax b- Chazacla-6 Upper lane (CA');
Keusuns A
chas ba Chatoclor- l6Uppealane(2");
-koisns
s)Chanaclo-loLowenlane ( ).
Ratuuns wen Ohgumunt in ouser Cane
chahacka
qiven chanaclah maina home
i S
abruad in ouencae
Rauns the same haraclor
quen characlo no a

Syntax cha <vasy = Characler LbLowenlase lkasacla) ;

Exampe:_chan ch- Chahaclas-blcuwexlase('a');


Ra lunsa
har cha Characla. 6Lowenlase ("A');
- Ruluns a
chas che= lhanaca l6Lowa lae (*);_
Ra

AscIL
AmexicanStandasd Cecd for
Inlotmation Tntenchange
ASCIL Codo hanges om O l6 127
CToto 28 chasoclo)
Chosaclhs98 Ascu ooos
0-9 Ag-
57
A -Z 65-90
a- 7-122

DoTam Code 6 obtoin AsIl coca a


givenchasaclor
Syntor int <va) =int) <chon_votialtay ;
RabLvs 65 6
chan x= A
Examp Vasial n.
int n= (int) x J
E

P
N13

Aulaboxin
Primilive Doba lype Aslo boring Wopper Ojece

Aulomatie conwesion Pamúbve Db ype


ins an
oljact ieqivaloxt Wopes
Clas is Koun Aulsboxing
Symkax <Wroppaa Classy <oljecky= naus <Wrapper clas

Exompl1: Thtge Lnleger 20)

mppa Obiece VramüEive Daka

2: Doulta a-nau Doulsa 2-34)


objec Doubt Wrappah Claus
3: leot 0-004
Plost X
uuoFlcat H)
oliet Flost Wrappa ass

Neecl Aulsboxino
lo pax a Primiive tyne dlabo a
undion hat ws Wrappa olipck as
onclion aoumnt

lo add
acdd a piniive elaka in t lat
a a y elmanh.
14

nbaxina
Wppea oljeck Unboxing Primilive

nbexing is aoppoxila Aulbboxing


Tis Sylam conVerlihg an oljacE
Wroppaa Class inlo Psinilive daka type

SplssPrimalive claka bype vaay- <Wroppa Oljacky


Exaapla Tnleger olj na Tnlages(20)3
int xaoljj

Neccd O Lnbexina
Whan the valueom tha Woppn oljeck
s 6 e passed l6thaunclion hauina
hasina
phimilieagumant.

When a daa rom araay ib


e sed as a phimilive olata
IS

Sampl om For Aulobexinq Unboxing


Unlooring
pubte class Aulsbox

pulbtie stalic void main (Sbúnar aI)

ink x25, Y
Inleaaa olj-ra Lrãger (x)/Auöboxing
I Lnbexing

Synbu-ou pinn( Yala atn Aulsboxing- to),


S aN-Outptindin (Valau otan nbering
N.
A sek charocls enloed willn dale
aualos Knouon Sung
Ex Compulo
23

l6 Pimatare pe daka e
Convession rom Sung
numbe3,
passi wfwn containsonly

S 0 S-18
in naLntegea possalht (5), or Val d
Integet Valua.Q5)

Sbing S ohe
inn Integ poselntts), OT Invalid
nkegan pYolusQ tS),

those unclons tth


Hou try
alnhalelioTalphanumeile sing tan i
throws or Callaas
NumbeafoAmat Eraption

atailalde in
Valus Q unclin 16
Java -5 or highes yeion

You might also like