0% found this document useful (0 votes)
28 views2 pages

String Functions

String functions in Java allow manipulation of string values. Some key functions include converting a string to uppercase or lowercase, comparing strings, extracting substrings, checking for empty strings, and splitting a string into parts based on a delimiter. String methods make it easy to manipulate and analyze text in Java programs.

Uploaded by

Kunal Chaudhari
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)
28 views2 pages

String Functions

String functions in Java allow manipulation of string values. Some key functions include converting a string to uppercase or lowercase, comparing strings, extracting substrings, checking for empty strings, and splitting a string into parts based on a delimiter. String methods make it easy to manipulate and analyze text in Java programs.

Uploaded by

Kunal Chaudhari
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/ 2

Stri

ngF unc
tions Descri
ption
 St
ring
.val
ueOf(arr) Conve
rtthee ntirearrayintoas tr
ing
 St
ring
1.co
mp areTo(St
ring
2) Comparesstri
ngsL ex
icographical
l
y
 S.
subst
rin
g(startI
ndex,endI
nde
x) Conve
rtsas tri
ngsi ntosubstrin
gs( l
ength
st
artIn
dext oen dI
ndex)
 St
rin
g.toUpper
Cas
e() Conve
rtsas tri
ngt oUp p
e r
c ase
 St
rin
g.toLower
Cas
e() Conve
rtsas tri
ngt oLowe r
c ase
 S1
.equal
s(S2) ComparesvaluesinString&r eferencesin
pri
miti
ves/
us er
de fi
ned
 St
ring
1==St rin
g2 Comparesonlyre fe
rences.
s .
hashCode() Gi
vesthehas hc
o deofano bj e
ct
s .
toSt
r i
ng() Gi
vesClass
name @hashcodeo fano bj
ec t
F
loat
.val
ueOf
(s) ReturnsF l
oatc ontentso fStri
n go bject
F
loat
.par
seFl
oat(
s) Convertsstringc ontentsint
oWr apper
Fl
oat
s .
contai
ns(s1) Returnsbo ol
e an&c h e
ckss tri
n gs 1
pre
se n
ti nstrings
s .
spli
t("
char "
) Spl
itsstringintoAr rayo fsubstr i
ngson
arr
ivalo fgivens y
mbo l/charac ter
 bool
eans t
ar t
sWith(Stri
ngpref
ix) Ch ecksifas tr i
ngs t
ar t
swi ththes t
rin
g
rep
re s
e ntedbyp r
e f
ix.
c har[
]toCharArray() convertsthiss t
ringtoan ewc har acte
r
arr
ay
 bool
eane qual
sIgn
o r
e Cas
e(St
rin
gs ) Usedtoc omp aret wos tri
ngs,ign ori
ngthe
case
c harcharAt(i
ntindex) Returnsc h
ar acteratap artic
u larindex.
v oi
dgetCh
ars(i
ntsrcBegi
n,i
nt Copys etofcharactersoftheinvokin
g
sr
cEnd,ch
ar[]dst,i
ntdst
Begin
) st
r i
ngintothes peci
fi
edc haract
e rarray.
 bool
eanends
Wi t
h(Stri
ngsuf
fix) Checkswh et
he rtheStrin
ge ndswitha
specif
iedsuffi
x .
 S1
.co
ncat
(s2) Concatenatesthes t
ringS2att heendo f
th
ec u
rrentstringS1.
 S.
rep
lac
e(c
haro
ld,
charn
ew) Replacesall
theo ccurrencesofao l
d
characterwithne wcharacter
 S.
rep
lac
eFi
rst
(St
rin
gol
d,St
rin
g Repl
ac esthef irstsubstr
ingt hatfi
tsthe
ne
w) spec
ifiedre gulare xp
ressio
nwi ththe
repl
aceme ntSt ring.
r e
p l
ac e
All(Stri
ngold,Stri
ngnew) Re pl
ac esall t
h esubstri
ngt hatfit
sthe
spec
ifiedre gulare xp
ressio
nwi ththe
repl
aceme ntSt ring.
indexOf(intc h
/Stri
ngstr) Returnsthei ndexo fthefirs
to ccurr
ence
ofCharac t
e rc h/Stri
ngstrinagi ven
Str
ing.
lastIndexOf() Returnsthei ndexo fthelasto cc
urrenc
e
ofthec haracte rorstri
ng.
 Bool
eani sEmpty() Checkswh ethe raSt ri
ngisemp tyornot.
 St
r i
ngjoin(CharSequen
cede l
i
mite
r, Str
ing.j
o i
n("-" ,"This
","i
s "
," a",
CharSeque nc
e..
.elements
) "St
ring");

You might also like