Download as pdf
Download as pdf
You are on page 1of 28
r = — | MODULE II. O STRING The String Constructo :- | String Claws Auppoit ceveeal conchuctom- A Seng fh 4 Seqpane eh Chasacterp: | Wen your crak a Stovg objet, ee. ake crcochivg a | Ste hat Cannot be Chan d. But 4 whateves | Chore yout have to make will be Ceeoted a4 120 | Song object . _cust_en_et 24 : CHETAN.R | Showy c= yew towg 05 Asst. Professor & will be empty + Te eats Chevgs cotth initial values Shrvg Como Chaya D) &- Uo cha (1 = ft", tel fc = Sh ); Ghvg S = me ring (thers); Sp bitabged il abe: 3. _inthalge a Gong by Spey 9 Sebron otal Py. 4 Gra, (thar cheat, vt ctastindex, int numebars ) StostIndex - Specrfiee te index at whit Subsorge begins. |__ mumbles - Specifiet m0. of Chasattey to ye 2 4. Corghuct 0 Shiva Object thet Containk the Some Ohasarts Sequente acter An Check - Showy ( Shing Obj) &- Class ee publi: Static voi rwain (Gra og (DL aa rs ue un way vat. f Shug S1= new Si Cony Shon 2 mw cing (8); dem- put privéln 01); Gychrn - out~ pointy (62); fee eee gasioe eet oulput’~ Taye Java. 5. Trchlig a Shng vlan gen a ly aheg: Ging Cyt asctéChas LD) i. Sin of osttt Chant) , tat Stok ndex , ot mumncbags) ayui han —> the atay OF fiat Th ea of tape conuctom —to~ chasackes Convention in done by wre degaule Chosaten ered | “hs. platem- Ee byte Cowal C3 = E68, 66, 61, 6&, 69, 105, Shing St = rew Srna (ase); | Syd. out. printin (ss); Steg So = ww Shy (Case, 2,2) 5 | Cyctem: oud: pathy C52) ; eudputs- Ai _ iia by (S2, iy freee | c. Congluct String fier Shreg Bugs : 6 | Steve (Sng Bag cBaf Obj )- 4. CString Constructor that Supports extended Unitede | Chamaths set. Shara (int Cock Pore, LT, wt choel Index, int mum chars) | cok Porntr — OM that cortorn, Unieode code Poin. The vrbtiyg Chr Ir conucked fom Aue, ‘vorge that begens Jt cfoatIndex and Yrs feo numthars, int LO todeRinty = need int C1 fos, 66,63,68 45 ee & igemscuk: prattin (String (code Points, 1:2) 5 Oudpuk: Be CHETAN. R Asst. Professor 8. Supposts Shug Builder cou Srv Sting Builds ch-Busld Obj) Ths commu Shvg oom the. Strrng usldes passed in she Build Obj. g . BH yet Stony - tot lengtn ©) | Gr has Qaatl= f 'a', tbl elds | Gring 2 = rao Ching Chass) ; | Cuca souk. parttin (s: longtt, )); \ bs € y aces Gen the numbed dhasatderr Contoirucl in tthe Bp a easies Woy a cat Fox tanh Shing Litetall , “Tove custorntialy conptructs a Shetwg Object. | Shing che Mabe" y Aye Sing ed | Because Cog objet ik Gooted 4or evety tong Utevall , your Can UNE Shag Litecadl any | plow pu tan Ure a Sve object | | Super «out pantin(Sebe® Logs) 5 | Ouput :- 3 CHETAN | 2. Concoclenadtn 1 sanieete | + opuctos, Concetenaty. two Shige ' produchg | | | | eG esontg Literal :- | | a. Stig, instonce. 1 a Srivg object os be vault. Br Se cml Gig s =" He ae age + ypate old"; | Sysem: out: pristn Gs} Oubpuk He je AT gpa old. | On. pracktadl une ef a) Conctenation tp When Coveodtt Ne long Shings. “We @N break Them into ualinl paul “aul wee 4p Concatenatr them - Ge Stila length = "Ths Couled Lowe been 0 long "+ nh OO ee Neto eetaniidcortly 3 Sting Conerteration site Otlaes, Darter “Hy pes :- @ | We tan Concetendte chs vot, ottwe | Gs int age= 4; a ‘ype cain | | Sting str = "He p* tag +" years old’; Sphin-out- prin (385 | Oubub- He jp 4 old. | int value on ip atrally tonveded ‘nto An Shring | “Yeprepentartio Lsitlum a Sts objet - | We ghould be v lela Wwuxing sthes types oposhin wilh te oe fr Shy ste> “fous "42 425 Systm -ouk print (ste); pubs- Four: 22. otter than Fours +. To gpk tis ovdput Shing Sire “ous "4 42); Sapo out pantin (str); CHETAN. R Asst. Professor is Suhut :- Foug: &- 1. Shog Cemasin ond “eSbsg! Tag Converts data into a Cte “reprepentatton = Conterenahon bi calling oveloade. hvg Conversion wetted valuaOPO defined by chivg. Valuaohl) veduema Slowey shat Conta, human-xodalele equivalert of the Vols worth whi + i Glled. on the object | Grn claws inplerconds ‘pSivgl) betaume & jp define by Object. Genet Teor :- Shing dota Geo Hovenide AeGhivgO) +e Box Class Class Box £ double widths double hexglc 5 dowele degth Box(deube 12, double h, double 4){ Fe obj, vabac#() els te Ging) mated | | | BR publi Stn see he { | vduen ‘' Dinensiond " ewidth +" byt depth + yl | : * hag 5 y Class toString Demo f publiz static void OK (Stig aug) Box b = new 80x (to, 12, M4); Shey Se “Box bi + b3 Sustem « vut> pont (b); I Convak box to Ste @ System uk: penthn (s) ; 4 Oulput- cua Asst. Professor | Dimensions ate Ino by [yo by 12-0 | Box b+ Dimensions ate '00 by Ivo by | | Boxs toString) mated audvmatically tokio when a ud in a Contote nation expression: | | CHETAN. R | 12-0. | | | Box objet A | | ieee ee | The Stony Clow, provides a numb:t of ways uh | Chosattenr Con be exhotted fom > Shvg bjork 4. chaxAt ©) 3+ | Tha extaca a & chasatter ftom ong. You can devectly wreth to an Individual Charaltes. | cha chastt (int hese.) | whee 2 Ae index ef Urazackes, “that you want to | obtain. should be non- _ | Chas th’, th = Nobo". cheat CD) 5 Oulpa ch = b 2. get Chowal) = Ran exhorts move than one Chasactey at a dime.» Genero_Form:- Noid agichera lint courte lant, int Souste Endy thas angel), int Aap it) Soutte Staxt— $pevefies she index He begining *, the Substring + Costa End - Speriges om index thet pe Ore pat ue end 4 the desired SubStoug . | taugd £1 - o%ay that voill Store the subshivg | |r ea Index witlin toaget at whith SubGeng usill be Copied « Se Shing = UThin ip a emo of the gitGtecs "5 int Stat = 10; a end lh Chen buf] = Mew Chas [end—stact] , x CHETAN, eget Chars (stort, end, buf, 0); Reser Sigtom-ouk- part n (but); Oudputs— demo 3. get bytes O:- This rwuthod roves “thu chasateyr n an array Pf bytes, TE Une dyeult Chasacter to — by tonvension. byte tl qa ct) geyeO K omoyt uneel when yeu ato enpovtinng a ® Ging Value into on envionment at does not Support -bit Unitode Chasattern. Br Steg Ste “ABC'S byte Ci be She ger Bytes 0); dye (int Ted CX be lenglh 5 cat) Siphon 0uk. peti ced); Output - 6S 66 ETAN.R 64 Cer proessor Ay to Chad Arca. o Converts all The Chatatteyr a Sterg object into a Chasacter Array - Gena Ferm :- Choa LI toChar Frere c) kee @ 2 “SdBIT"y chad 3 th = Sto Cos O;5 fox (ink 120 CX Chr length t+) Sislern-ouk- penithn (chi), B L + | Shia Comparison & cuetan.8 5. qyali() ond eqpelbFgnoee fess 6) me mat choo Ste 4 | equal od Compare hoo Stmngs od cqpalcty | bookean eqpals Object tr) Ste > , oq pad 4 Compateal vetly the | __ tog Sa | TH ovehwns tue Y the tei | Corathts ty The Same owdea , and fale otlenwotp 2 | “he Compannon ape - sensitive | To perform & Comporiaon thedt jyrows Cone digtprontes, K equals prove Cone O) smdtrod. When it Compotea woo | AHL. +0 be te Same % a-z- conta the Same | Steigp it Conprdees boolean eqpals Fyre Ge (Srey ch) Stes & Song Object berg Compared vith the invokin Stowe object. FB vedumm the 4 tte Stings Costar tha Lome | Chonarter, ir the Came order, anal fe pitaaojte - | Grompler— Shir cts" Hello”, | Shivg r= " Hello; Sing 227" Good ~ bye "7 Store Se "HELLO"; Sipe -ouct pond +" eqpal! + <2 ph oplg cl eguab(s2)); equals £2))5 System -ouk- pnintln (61 + Neguah' + $3 phot Sh ely - outs pondln (sl pte Masy graph acl epua CH); s 7 ; . . a = iste puts paatln (sit! equa Tpnte ones Sp HP See aah 7 aul Hello eqyals Hello > Trus © Hello equals Good-be —> Fae Hello eqpals HELLO > Fahe | | Hello equaleTgmove Cone HELD > Tre. peta. | | pgst. Professor | | 2 yon Madebes C) | | Comparsen a Speeypit. vagion imide a ching voit ometig Spee ge or in ancthaa ching. | | Fae pon cvloaded fotm “that allows you to Gyneve ane | in Conparizons + | | Gensal_form ted, int shr2Stoetlnder | | boolean ~egion Matehesl int staclndex, Shneg | ont mumthay) | burtim wegen Mats (bean iri it ates, Shy | int da-StoskTudex int numchars) | shetTndec = index of ubuls Toe vigor begins within “he tnvoka | Shri objet “e of “e | sho .- Stoing being conpored _ndex at whith The Companion wi mum clrath > Lurgln of te subshivg bug Comparer | ignove Care trap, te Cre of The chroraters |p goede | tale, me if congidesed . Ul last vottan s¥2.-| [Sing Sd =" lone ; — Gling Stv2 = “ Come "> if Cotaxepon Mates (2, Sh2, 0, 4) { w , Syplem-out patil" trivg Medthad ); Bnd pririnC* cinta not Medelad”); Gtrig sd =" COME") it( hg Mota) not Mates") 5 | ae | Sypeen ou panto trig | 2. steph) ond end wht) Tere method ate Specialized foems ef, ae Glos} WethO) > deternunes ohucthes 0 ge ¢ vy begins usty o epecitied String - With) > cletetnuis walettias ogiven Shi endy uit gessal feean :. beoltan clort With (Shing ch) boolean emdsWitlh(Shyg sh) Ste py The Gri bait ol tthe. eee matthes , chun pv Othanioine false th vehuorteal- SE WWeltome". ends ith ("come"); " Weltoma.stacts With ("Wel'), | A Seeond form + Chaat With () , let yor specty attcig | point : | boolean acblth ( Steg hy, int SoetTndex) | slostslok» —> Speen the index into the Invokiiyy ~468 | ot wudk pond the Seoet will bein . a "“Toobax" ter with ("box ", 3) ok ‘dw tue. or protesso i Sepak Ouvusie = THe eqpahl) ‘method Conpates He chatacters trode a Ste Object ae pesado compas tus0 objet “refuantas to eo. whether “they meh to ta come tnétonte- Go- Clacs Gyalenlot Gal To publie static, void ™a (Shrngg £2 a4) f Shing ot = "Helo"; Beng 62 = ww Shovg (sn; Siplem souls prints (St + Neapole" + S2 th pl Sh equalsCs2)) ; Sptem: out. pastln (st Mea 4 ations (st == 2); Ty, Vauiable, Sh fis tp “the. Shigy instante Created b | Miktlo". the object ~veeatsal to 2 jp Geabeal with £1 2% an Mnihalges «Thus, Contents of the -two Sov objedh ote, [identical but ‘thay aa” distin objext - A @ cers eR yuat to Fino olathe os than the rete A shiny pr len Than another i, Coma bef. ts oe siedemty, Uae, geen an onete tf it Comes Ofte to jp Wonton , pal to A Ghivg othr in cickionasey ordeg: General Form :~ zons int Compan To Ching eh) ote a Value Moomi eo “We pence String ih lew thorn Ste. 20 Te anole Stony h grein ston She. 0 The ching’ ate equal. | Class Sort Str ¢ | fate Shor £3 =¢ wweltonu", "4o", “SBT” 4; pulolre clade Noid main (String ongs cpt doe Link F205) j SOF lagi 5 jd Boy Unk Ve jal U4 ors length», ut) { if Cow LIL. Compare To (orel yj) < o)f ® Stng + = awlfl, olf = or (11; | awfil =t; | | 4 Sys oud prnitln Cowetf3) ; i! lan ge SaBIT oho | Weltome to 4 ee want 4p rove Cone if tetenees wlan comparing uo cts) Ue CompateTo Tgnove Case O) int const Tgnore Coie Sting chr). Two methods ate > indexO#() —> Searcher fot he feat octuasente, Of a JastTidex OFC) > cepstler o@ the last ocossente. of & Chasackr of culostivg + ot wlath he 1 | “ye methods “vebuen “the index Chosaths 08 sulbstewg was found: int indexOF( int th) ae fet the fiat Otureente characte. | int last TndexOf Cint ch) > Seatelr pe “tee test Onustene | of a chasactet. | Her Ch yp the Charater bei | To conatts fp te. fat ov look Ocuszente Pf | Sulocheing | int inlet Gh it int last Tndex OF Hae chr cpevitin Toe i You can pet a Shoat 7S at ta Leaech Yi | int index Cint ch, int stot Index ) ak, | int lost Tydex OF Cink thy int Ctaet Index) ote aE haat Td) vat index CString FE, io i Laat Tinta OF[ Sting hey Ot toat-Index) oatmeal fg inde ab lal, port Hoe ool beans: ee to erebr indax 0? (4) =" $+ sa 0t +); ellisg. lowstTindsx OF ('€")) 5 Shing SF Sytem: out. poatin(* § era out: patty (* lant Index OF (e) om» oud pontin (" index 0 (40) =" S index OF C40") 5 ihe out - pratin (¢ indy OF (4 2 “45° md Of ('P, 2); Oubputs indrOt (4) = 9 | rite) 2 i | index of (40) = indbx OF CHD) * Modifying a Shang @ 4. SubSteng () Extoeuss Sul Shug for the main Shing. Geoual farm Srivg CubShrvg (int host Tndex) Sting | Cint ChastIndex , int endTndex) StottTndex — Speuifes ta index ad whith SubShing will begin. end Index — Spevifies he index ot wluth Seale will end. Gling She= new Sh (*weliome") ; Stig 1 chr. subthiwg (2); Shvg a = She Subthiwy (2,5); output - ey Come Kenan §2 = eo | 2. Coneect C) Concatenat two Shame Sti concat(Gvg sh) | hin mated cnc oa mew objut at coining | invoking Shing wrt The contents of cy appended to | te end: Shiva ga = “one; Ge CS ct Contat ("490"); Oudpuk 2 £2 = onetwo | —— | 3. Meplate © = | He has hoo ferme: | st veplaca all Occurtenter of Ore Chasater in the involv Shing wit another Chaaacter- Stovg replace. (Chas owipenall , Chas veplaenant ) G- Shiyy $= “Hello”. replace ('1', 'w')5 Oudpat :- Hewwo * 24 — replaces one Chacacter S4pence uth omotes - Stovg veplece (Guns Seqpante. ompinal ChosSequnte ; locenent) | eee sea ae *Hello' veplace (“ello * Mellow") 5 owput:- * Mellow cue, | . post: PAST | h- tim) + | sting fiom war, any lading anal talivg volarleaparee String tim) Gr String ee" Helly World "him O;, ewpul Hello Woeld, By ye untgul volen yet | duena @ Copy 4, the Ee bos been removed « | promn Ure tora ds « a tea eee a The Valuc 0F0) wetted conve data fxom ‘fp internal format into a human-veadable fem: Static Stovg value Ot (dowkle num) tohe Stovg value OFC to num) aq ValurOt ( Objet ob) CHETAN, Siva Valued (clos cherst2) Valued? CD ie Ged when a ar sepeentaton of, some oles “ype % doth jr needed. You ton Coll “Hii meted lively wrth omy date typ aud ot a seoponable Shivg “epeentaton Stare Stowg Value (cas Chars, int Sostlndex » as meted allows gos peefy a subset of a Chath te tnat bold “the Chasadter stastTndyx — fr te Mndex into the of thuatten, ot tla, the dvived Subostivg begine. enum Clans — Spewrpies tae longa of the Cubothng. Chargng He Spe of Coan Witin o SEG Stony ctoLowerCone C) | rng to Upper (ope C) ApLonaectal) — Conviahs Ghasackex fom uppeeore to lLowetare « toUppeacorel) — G@rnvislh Character fom lowercae fo Lppertare. | int purethars) +—___ 2Ger Stowg é =*Onjginall’; Syaslern sout- pratt (" Uppeecgne # My S.t0Upper Gse oO) Systeme -put. portly "power Cones "+ -¢ to Lower Cope O); oudpuk- ORIGINAL orginal CHETAN. R Asst. Professor Add thon’ Sing Method FOR Ne 3 ax “method Description int codePointAtint Retuens the Unicode code point a he loation specie by Aided by I2SE 5 | nt codePoimBeforeint Retuns the Unicode code point at the location that precedes that specified by 1 Addos by J2SE 5 | int codePointCount{int start, int end) Retums the number of code points in the portion of the invoking ‘+String that are between start and end-1, Added by J2SE 5. pooleen contains(CharSequence si) Returns true he imoking object contins the sting specified by st Retuns tls, otherwise. Added by J25E 5. | Fppoteen contemtquaa(CharSequence str Returns true fhe invoking sting contains the same sting 3¢ str Otherwise, retums false. Added by J25E 5. boolean contentEquals( StringBuffer st Returns true ifthe invoking string contains the same sting, | | str Otherwise, retuins false. | static String formatSteing fst, Returns a sting formatted as spectied by fintsir (See Chapter 18 Object .. args) for details on formatting.) Added by J2SE 9. | satle String format(Locale Joc, Returns a string formatted as specified by fmtst. Formatting | Object .. args) details on formatting) Added by IZSE 5. |pootean matcheststing rex) Returns true if the invoking sting matches the regular expression passed in regexp. Othersse, returns false. t ‘int offsetByCodePointstint start, int num) Returns the index withthe invoking string that is oum code points beyond the starting index specified by start. Added by J2SE 5. ‘suing Retuns a string in which the fist substnng that matches the replaceFirsti Suing regexp. ‘regular expression specified by regexp is replaced by newStr, | String newSth | syring : Returns a sting in whch al substrings that maich the regular |" replaoeam Sting regexp, expression specified by regExp are replaced by newStr ‘Sting newSt) ‘Stang | split(String regExp) Decomposes the invoking sting into parts-and returns an array that contains the tesuit, Each parts delimited bythe regular expression passed in regex. ‘stringl | spli(Stiing regexp, int max) ecomposes the invoking string into parts an eetums an array that contains the result, Each part's delimited by the cegular | ‘expression passed! in regexp. The number of oleces is spectied by max. If max s negative, then the invoking string is fully | decomposed. Otherwise, st max contains a nonzero valve. | | String fmtstr, is governed by the tocale specified oy ioc. (See Chapter 18 for the last entry mn the retutned array contains the remainaer ff the invoking string. It maxis zero, the invoking stnng 's fully cecomposed, CharSequence Returns a substing of the invoking sting, beginning at startindex _ SubSequencetint startindex, and stopping at stoplodex. This method ts required by the ing stopindex) CharSequence inte! face. which 's now implemented by String. ® | Stang Buped -- | hogy owopsepent fred length :rmmutable Chovathes Seppencas + wable and wrioble chasattes Going Buffer seprpents ge vies may have Chosatteyr ond Lube shivep irpesded in he middle OF appended at the end. | Steg Bugs has move Chacacterr preallocated oan ate. attually | muded to allxo ~w0om ee gfouth | Shonghayys Geer a | Fe hax # Conshnuctys :- 4. Gevg Buyer O) | Re Fakes no pasar? , but réperves room fe U6 Chosarter >. Se Cent, SQ) | BH takes fregen cagurar that eplutty cele He sige he buf 2. SrrvyB (Sh ch) at that po te intial Contents FH ateyts She mw “) a “e 1 meee Charartexr voither oma, rapeved “BOM ms YYeallocotion- Tha ‘te the DO cg ~reatlotasho tat fake pla: 4. Sha? Cusstenpene. vss) HB ceoln on object hat contains the Cortaninasl 1) Chae. ! 2. Chasater Seqpone | " Tong) aml Copacity (= Longt O) rated ~rehuims tha cutter} logth of Ching Ripper. yt) melaod vetumms te total allocated capacity « Gonuaal forrns = int 0) CHETAN Ee | it Gopaedy oe | BE Deng Bypes cb = raw Gig Bypea("ste17'); | Siglem uc: pontin (Nang = "+ cbslenghh©d); | Speen -oxct: pont ("capacity =" sb sCopacity ©); Output? Corgth = S Coparity = 24 [becaune Ib addechonal Chacacters audvrnarhcally added - enpura Capac Or “ran ethods ip 703 pt panllacng voor ot & Catan numbed chosattors after a Chivg Buffy is Comphnucted - Gost fo Nod expuse Capacity Cint Capac) BE Gig B th = new Chua Bugges ("Ise"); "I ees (24y;, - Sygbem oud: psntin (" dpaaity * + sb: copatty©); t — | Sethengthe ) > _ ex | g | cobs the. (ongtn of the buffs wrthin a Shieg Belge jot: | » | Nid setLengtiaCint len) coger | hate tem > Specszts he nga of tha baffsr- | hun you metegne te sige of the bugs null Craracters | ain added +o te end of te exiting Gaffes | ¥ we call set 0) with a value ton than “the, warsent | alae hummel by the Ung, Hum Chasacto stored boyonal dhe yew length will be loct. Choa) amal cet Chart Cd :- COMO) One a Cheat) reduens ov Single Chatacks obtained prom Shoig Bos? ebChagnit) ssdhe Volun of chats tin Gea gawal fem cha Chast Cit where.) void cebthan At Cit vwhuse Chas th) G-String Buyge tb = m0 Peg Bugg (" Helto")s, Syplem « ouk poi in (" bugfe® begetet" +£b)5 Syskon spud. partin (" choot) befote= "4 gh. chor (1) Shoecebaeht (4) 01°); Sb» Set 2)j | Sphon oa tn ("hg ates: "+ Sb); | Quipuks buffer = Hello | chase (E) befete = & | buyjer often’ = HE i foe | get: To copy a Sub Stowg eh a Shonyg Boggs into an aay gprval oar: void get Chas Cint Couate act int SousteEnd , Chas tagetl 1, ont ‘gn SoueteGaxt — Specifees ‘index ef; bepinnres 4, Substrivg . Sou Grd - Specifies index that je One part the end of the derived ubchvg « nage CJ — amcay that Sows erkackd text. ma Steet — He index witiin tage of salute “a tage will be Copied paned ih asget stash Pp’ : Chas C1 buf = md Cas Dal a P fe Shingg aft b= raw Shing Page ( Welton ys Shiget Chass (3,6 buf 2} 3 i : cctenccles he Stoingy meprentahtath ony end % the tooling Ng BY SriwgB append (Stig she) Sing ae append é sai sl Pring Bagge append (Objet obj) Singtget = mw Ghovg bypen(20); Sz She append (ta ="). append (a). append (*! "toGrvgl, System outs pentha (9 > a Output >= a= 42! | insert) 1- - a) | Tryerts OMe hong flo oncthet. Tr calls Chg vahuxO#C) | 4p cbbsin he Sng wprpentaion of talus. Hy cll vat. Genesal pom: Stora Balen insect (ink index, Shrug ee) ane ivg B inseat Cint index Chas’ Ch) ‘Agst Professor So incoat Cint index , Objet obj) inex — Speeyfis tae index at hurls pois! the Ehsng will be inyetted into fovoing tong Busy objedt. & Sroyg Buff Sb = new rygagges CT Joval'); epeinset (2) " like"); Sytem out postin (S45 ouput TT hike Tove evese Lt on Yevnes he Chasactets witlin & Shing Budge? objet m:n Pi reverse) Bx” Shy Bat = Ts. revee C5 Systm ou patty (8) % Qubut :- 7iBTS rao Shvg buf? (“sTeIT'); [ alice) od blew Both functions delete chaeate, oiltuin Stn | Genwtall Form :- ii Sng buys dee Cint tact Sodas it end Index) | rong Buys delet Chaodt ( int loc) | GuukC) rated deletis a cegpunter of thaeadters | the rmvoki object. ar ‘t die Soet Indy — index of tagt chasactes to Yemove - endIndex — Index ome part the lavt Chacarted to remove» celubthartt() rmdted delet “re Unatadtes of index specified | a loc. | &s- Sheng Budge b= new Srvgy Bagg (" Weuome"); | ch. delete (3,7) 5 Syatom. out party (Apter delete > Math); | Ch: delute Cont (0); System: ob printin (* Att delet: Uoaottt +56); | culpa, lute * come Wel | Agtes delatilhoe fa replace L) :- ~Veplates one Set thasartes with anotur © inpide 2 tonsa Seated BID ig BA ~eploue int act Tndey. pint end Index 1 Soy Str) | Te Culottav being veplawol 1 speuied boy indexes cael Tiolo | amd sedde! Te aan ae tp sl tn ctr. | CHETAN. Asst. profess [ee Sigg = rw Sng Bas (er i page Siomabypes Gouy cussing Cink clack Indes, fot end Index) aa vee The feat fem wehuons tue Cueshe “that Stoolr at tot Tradex and sum to he endl & fhe tno ‘g Stnyg Beer objet. Tre Second foem rections Te Seubshs that took ot ClootIndex anol uns Huoygh end nde —L- o> rng Buffs ch = row Chri agg ("C+ ia parcel”); Stony? Shee'* Sb. Substowa(Ht) 5 Stog Gh = She SubSr' (6); Shrieg Shed ~ hy Subtotal 6); cup che = cat = Ste = powsgel cho= WK Method ‘StringBuffer appendCodePointint ch) int eooePomIAtint Int codePotnetortit 1) i codePeintCountint start, nt enc lt indexO4 String st In ingexOf String st, int startinde) int las:indexOf(String str) int lastindexor(String str, int startindex Addehonal Ching Bufgs Mat ods *- Description ‘Appends a Unicode code polit to the end of the invoking object. A oferance to the object is returned. Added by J2SC 5. Retuens the Unicode code point at the location specified by / Added by J23E 5, Returns the Unicode code point at the location that precedes that specified by J Added by J2SE 6, Retums the number of code points in the portion of se invoking ‘String that are between stert and end-1. Added by J2SF 5. Searches the invoking StringBuffer forthe ist occurrence of str Retums the index of the inateh, or =1 ino match is found, ‘Searohes the invoking StringBuffer for the first occurrence of str beginning at startindex: Retums the index of the match, or 1 ‘fo maten ts found, ‘Searches the invoking StringBuffer forthe last occurrence of si. Retums the index of the match, oF ~1 no match is found. ‘Seorches the invoking StringBuffer forthe last occurrence of str beginning at startindex. Retums the index of the match, or 1 9 match is found. int offsetByCodePointstint start, int num) charSe subSoque! ‘lot startincex, int stopinaex) oie tin ToSizet ) Returns the index with the invoking string that is num code points beyord the starting index specified oy start. Acded by SES Returns a substring of tho Invoking string, be nningyat startindea anc stopping at stopinder. This miethod 1 requred by the CharSequenee interface, which is now implement StringBuffer Reduces the size of the character buffer for = mors to exactly fit the current contents. Added by 1. a indocOFL) amd (ost Tra PC) - Sting Bujpea sb raw hrvg Buffs ("one uo one"); it >, Ce sb.ind 0+ ("one") > CHETAN. R gmat port (° Fig Tndoxs "+ ¢) 5 Ce cb- last Tuk OF ("one"); Som cut prin ("baat Induce Fiat Tndx : 0 Quo Lat Index: & | Ging Balas t+ Tdenhtal to

You might also like