Meltod pretotye
777777777772
PurpsS
int lett) Cou th no. o Lt Sophs.leatuO);
J
/20
cla preseut u int'=
tt Stnnj emqti() I l-
3 20
|SeplmR= java", lenqtt(); //4
Chai claAt(iutinda)exkactea
SecHed
ed ta
idex no .
car Sopln(é. chasAtla), /2'
Chas ee 8ebaAt[á); lch=p
3.claAAt (o) ; /extra cto 1st cbai
.
CharAt(3.lengt() -1), /Lastebar
ChasAt(2),7/inhnC enrer
intindex0f(lord)zeturusfirstoecwans ict . indexdf[P'); //3
index no positien fe le
speciHed chan
3. indexOf CP"); !/-i s zutuanez
etunS tJdar vufrund
3earding tt Stmn19 A index0f(8.clasAt(s:,und
rom tta begtnninj| $: index0f(8.clasAt(s. lemgth)-4))%/5
index0f 'P',s indexOfCP')+1);7//o srdocc
int lastrdeOf (chasd)|retenslantocc it . Laatldexof(P'); /1
posihen/indes nD: 0 .LaatIndexofCP); /-1
Specified clar s0arckind space)
&tung fromla emd 4Lactilndex Df (32), /8 (32 unicode for
Stm ubstingnt bi-de extpradh past ofsin Sting 8 ubsbuna (0,3) /Com
int eindex) |jrom binderlinduded . substiins (7,12),/APP
to eindes (excluded) 8subsLg (16) /ton
c2 3 67 Appucattol
S- Computor
h
°
B = Computes AppltcatG*
Metod Purpose Rd
8.tolou@ilaso); /omputerapplcatio
trtolouoeslaae O Conveto all chaiinShiua
t a t a i n to small Java 123@" tolouoenlare(),jave 123@?
Cas.
COnvets all cias Stn8toUpperCaae(),//CoMPUTER APPLiCATIDN
tiug tolppenlaae() mt 3 i n g to
capital cade Java 123@''toUppesCass{), // JAVA D3D
3.8tusWIT"comp"), /false ca
olean stastsWith(String)check if tlesing |booa Ve
beqining uoit E 8Ataatstoik"Comp /true
speciiedaDing 8.3tasto Oj t("AB "); /falae
3.erdstot("TIO"):/false
colean endsh(Stnng checksi tesiiugbooleau
L endina Lottmte . endo Ortt ("tien"). /trie
Specfiek zin 6. endolOi ("Lns'); /fal ae
("beok";/ConyuterAppticaneiki
itn n oncat (Stnna) oins/Loncatenates Smngs.concat
t i n q at Eu yava Locet("bovk"); // javcibookk
end of first sÜing Loncat("boole"), /va bort
Cuotdut pate) java",
oceuiang java". eplace(a#), /jnv*
fnn replace(chaA ahus| replecesalk
char wilE Stmng| an apple". replace(32, 40), /aniapple
32-SpaE
+9- 1
dar nchasold
heo cAR.
rlverses a slus Jfmajava".de /avaj
tnn reverse(Gtoona) anaple". revese); //elppane
removes exra( Sfmnq|Java jun " . t ) , i[javfu
Sting tnm() leading trailin java fun ".tnml /javain
Spaces {rom t
stungTn betoecn
SpaCE3 remain asit
A a nS P p l e
Leadi Triligl
X
exra
equal(s2);
Compares 2 Srings|bcolean
S1.
bolean equals(Snng s) c l a bq cha KeYwy
alac ufa mismatrh
found
Caal&LMgtivekatue
n(defaulty
SbingsSoolea S1.equalalqnorelaae (s>),
kolean equalslqnovelae(hna) comparls 2
haib eiar, Ste qmal(52) 31 equalslqneve lua
Retuns alee itaind S S tnie
(s
Java Java tue
7/Snatrl
is fet
Cae
slnSihve featuad Java Jjava falae
Java2 Java 123 Jala e S S2
Int S2 Si COm pare l o(S) O
|Compa res 2 tn ngs |Ivnt SI
nt compavelo (tnugs)
g 0 . C o m e a r e l o ( g o a t " ) : l e x i c o q a p h i c a l l
ABC ABC
CompaneCn Unicode
ABC BCD -I
Cmp ou lenqtk Volute of clhun BCD A BC
( 6 6 -65)
retusns'int diff s
A 50 -
Can
SI S2 70
A12
AL2 A -17 (32-49)
SI S2
2
convertb to shm ng Lnteaca tostmng (45), /l 45
Shing totaing() Lntegea. toShnnyt 3), /"a"
Float. valueCf("80"), /80.
Gocusg vluelf ( ) Convets latri vuea| S
eStn tpe to int x=xteger.vadue Of (37");//X:37
Covresponcti u
U m e i c vadues. Aoatme Foat. valueOf ("3-7'") m» 34
double k-Deuble. valueOf (°3:7 D;//4=3-7
Slvinqs declaves | ntlized ava
Hoo ae
Snn Stv
str av )
Stnug Stv "joavo
S n stv nes Stnng (java),
Stnno Shigue
SB are mutable (can be modhed
Sthu4s are tmmutable
CCannott be changed )
be
Stmng type objecb have SB objedo length can
fxe Engt chamged setleagt)
made m s8 objecth Aellet tu cdange|
to Save dhanges
a e s objed
Stnu class,
reated evey ime
L e t ) , chasAt)
replaceO, revease(),capaut
Stiugsufes sb= neoJngBmfer(jaa
Sti str,
ty Sh, Strigffes clas paat of java. laug
ohat ShnusKule claos ?
pat ofjava laug
3B e mudoble ie cam hemodthed
. SB creat ed o i t neLo epeIator
StnugiPex(),
a) StngRufex sh= neio
b) StmuqRu le sl -nes Srivgblfek("java"), capa
c) Stnqknfos Sb z D- he.s SfrudBu ffea ( )
a in- 15, .Stn Jfer Sb= neastngbu/feri
1 falas
Cha racter. isbngrt/'4')
beolean bodean bool- ruc
beolean isDiqut¢has) chles if te
specified J|fai
cdhana dgitornot fCava tea isDgit('S))
booleanb
( ) ,/me
Charate.isletes
boolean
oolean isleteca chks fO l t preseMce boalean b lavatea islete('4 ),/fal
ofallabet (A'>, a-z)
beolean
(4, //+
boolean blavader.isletelvbat (B),
booleanisleterdrdbet{iha chk e-t i presenLe /t
leter (A-}, a)ov
gits (o-4)
boolean booleanb= lharcote. isLaoer aea), //t
tageufed
sot lecn isLouoenlaaeldax ehkif
cha o m Smal
boolean b-CharacteA ISLocoerbaa(A);
Caoe Dw not Uppenlase(A), 11E
boolean booleanb= Character.is
lkspeoher UppelauC'a); /f
peiean sUpelouda) chksif
clan in im uppey boodanb Character.ts (65),//t
Capitlcasë brnut
b-Charactes isdlutspce
beolen b:Charactex-
beslen
(32),/7E
isWutspce (32)/t
boolan
isNtesuella) elk fer
coktesaceo
dcan
haracter.loloeeilase (A); 7a
ckas chanch
toloolae (da)
Convet speuhed chaLdd Charccter. toloaenCoeAS))/|la
chas
chan to Small case Ranch =CharetertolocseroCa)a
el =Claracter-toUppenCase ('a'), /A
wnvesbspeafied
cha cas
Aas c=Claracte. toUppecaa (A ). |F
toUppenlaae(la)
clas to caplidau Chan ch-ChavacTrtobppeae (17), /A
Chks. Convets
Rdt i chat
2. RAt i boolean
t o UpporCare (char) topperlanel)
Charactar class func Shing cles fune.
Converts a charate Convesb all t charatess
to Capi tal Cae preset inSmng to cap1kal
Caol
Rdt char RtStnng
e n ch= Charactex.tobC('a') Stnngstr="java',to Uppeslae
IA /JYA
Siwaa pest of java.lang
isLooealaae (chas) tolooenae (chas)
n v e t sperified chas
Cksf speufied t o SmalQ Caal.
Cha m small caal
not Rdt cl-as
R d t boølean
chanch-(hAradetolowerlan/à
eaCLAradteisLouoenlant(a')
true
Stmilail be Characton c l s func.
Oap pea class wmps lke value of o pè m an
pnm1hve typè a"c
m
biect
pakt ojava.lan
eght Orappe classees
nt Inteqer byte Byte cha Charoteh /haracter clnc
long Long
shot Skort
Host Float booloan Keoleam
double Double
UtittyReastma to eme l & pnm1hve data type
I COnvert, Stng
ntx= Intege parseInt("23"/br- readune)
int x=Inteqex. valueDf ("34")
a a y to Store pnmihives os obcls
ey Inteqea mint- neo Integea(26),
Double md = Meo Double (2.6);
Aame e e orappeA class tew
double Double
Lnt IteaeA d ) booleanBoolean
b.Char Charactes
clas
folling orappek
Jame unc. o
OLntege
pavselnt), valuelO, tosn()
b.Chaactea
lenttl), chaAt(), ndex0f()
c. Double parsebouble),ualue0f C) toStmg) ,
m appsopte/prerequisite data type
GStore 23"
Lntx Lnteger. pavselut
(" 23")
intx Inteqen ivalue0f ["23");