Java Session 11
Java Session 11
Sthinglchaehl,nt si,intEn)s
{ 3 , ' , ' T ' , EEJ
eXi_chan chtJ
S i n g S 2nLOSEninglch,1,3)s
S L, T, E
Stdag obj ).
4Sbing
R;'a A v ' , 'A'}
chax cL]=
St =mu tHng-
Stxing
tung S2 nus So:ing s4);
Sugken.outprintdnls i)s
USyslem.ot.ritln lsa
OUTPUI AaVa
Metheda
tho. ubung à tha no. of
Sing angth-Length e
chabeaclA bresent 0 n
mtax-
chan
int legthL',ip1,'T J
Sbunach)
Sbung S
Sbing nus
OUTPUI =3
erm.oul.brintloCRITEE longthO):
OUTPUT25
yshm.out-println. (s)3
taing S "Fiu +(23);
Syslem.ouit. paiotln(S)3
t Convexsian.=tasbingC)
oloubludth,height, depth
box double u dou ble. h, dauble. d)
uwidth =WS
dnpth d
heigut -hs
class dlumn
OUTPUT: dimensíom 10 by 20 by 30
bordimeruion lo b 20 by So
Charateh. Crhahm
char Att) exthace or u t Bingle
chanad fhon gtaing-
yrilas_chax. charAtULint Pi
chau
"RLTehar At(1);
ten.oiut.pintln lc)%
UTPUT 1i
othuuie alse
EquallgnorCasec)zetns w boh the.
8tiing Nlunn nuu both heiring_arL_
amit s onlyspellbensitiu. inot
Case seniHue
Example
ciass 3imilat
OUTPUT
false
False
equals OJeHIeS
chaacler nsid
Equals mathod Combare the
a 8ung the Z obeseator tompase Tuuo
obiect VH/ene. to 8e whaother. thy
yO 7D Samenstance
Uclass Comba
public aaic vofd main(Stuig axgs l1)
Sting SL RIT";
2u StanS2MwStdng(sL
ysem.out.mtln (S1. equals(s2).
SYstem.od!biln(SI=='s2)
false
oute
Poge
ég Sttng Si = "Hello"2
Stufn s2
S2 SLS
Sysem. ot.pintln( Si=s 2);
SL
H E D L T EO
0UTPU uR
Sbang Seach.
indexOf ) ::=_IE Escaueh br töut occwanu of
achaKacir 0n uhslung ai
JastIndezO£C) E sdearah-yot ho last_occuram
of charackn on dubskun.
nsv alt Caseesth method
ulusn thr inde mumbex)at which t h
chanactnO Bubsbune uwafound OH HOluhn
fon fatlune.
6ynlan
int inderOf (int_ch ):
int lastlnderOf n t ch)s
eg class domo
bubletabic vnid main(Sing angalI)
SLingS= java is sople "
Sysle out.pritln s.indax0f(a);
Ssttm.out.pintln s.latIndex0fCa"
OUTPUT
odiy a Shingi
aku
Substring(3 We can èxbracta
Substing mcthod
sthing Uusing.
äunax Staing ubsthing(int i
oh bsbnng hat
hat
Thu punna acaps
begainat _indix umben 1 and un
Utohe.end of he gtöng
yntay 2 1
class buffor
public sta He void mainlstung aHas I) |
PLe
StingBuffo sb=new Staing
Buffen"RI7')
Sem.out. þrintnlsb.kngthO)}
uslen.0ut.pintlnl sb. capoiky
U):
OUTPUT : 3
Not
*JheCapai mothod mado koom
Jor o addi tional chauacken auttomaually
charAt BsetChaAt
nax
cha chaiAtlint i)
yntax
vofo &tChauAt Ent i cha e)
OUTPUT S S a4o
Eingent_one sting into
mthod Ínsaut 8 n g a t
anotheeh
n y pecihic no.
Stxing Buffer insextlint i,Sbino
urhntax
yskm.cut. piatloi(sb)
OUTPUT davasinple.
evenaeO =SE u uLed to_ se tho
chaai uuth in a 3tungBuffe objtct,
class b auk
Rublic. static. void main
Stng augiD
Stu ng Butfe sb =rag
Stingbumo
(" ahd)
yelen.cut.pitlas
Sb teveuet)s
Syslen.out. brintn (sb);
OUTPUT abc
cb
Sbeplata(4, 6, "wa
ystm.outtpiiln lsh
OUTPUT q wawhut
2ubstng)
poHtion Oof h ma:thod uns a
8tinguomSbungButter
wns,
yntax .
Sting substúng int s)
Shfng SwStrima
Cxample
clas& demo
bublic stakic void mnSting auas LI)
Stsna Butfeu sb =nau Stxing Butteu
ava is simple")
Sting S
S Sb. cubStaing(s)
dystem.out.þrintkn (s)
S sbsubsting (8,14)
Syskem, out.briottn(s
OUreOT Simble