<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ritika Sharma</title>
    <description>The latest articles on DEV Community by Ritika Sharma (@ritika_techiee).</description>
    <link>https://dev.to/ritika_techiee</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3236693%2F0408781f-ae45-44e8-876e-db0f7007d201.png</url>
      <title>DEV Community: Ritika Sharma</title>
      <link>https://dev.to/ritika_techiee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ritika_techiee"/>
    <language>en</language>
    <item>
      <title>Extracting first character...</title>
      <dc:creator>Ritika Sharma</dc:creator>
      <pubDate>Mon, 02 Jun 2025 06:47:21 +0000</pubDate>
      <link>https://dev.to/ritika_techiee/extracting-first-character-15i0</link>
      <guid>https://dev.to/ritika_techiee/extracting-first-character-15i0</guid>
      <description>&lt;p&gt;Yesterday, I was solving some basic problems in Java. Specifically related to case-check and finding vowels, and I came to know about two different extracting methods !! &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;in.next().trim().charAt();&lt;/li&gt;
&lt;li&gt;ch.charAt();&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Someone who is a beginner might often get confused by these methods, &lt;br&gt;
So here is the explanation of what these do...&lt;/p&gt;

&lt;p&gt;If you are lazy and don't want to write much code, then  &lt;code&gt;in.next().trim().charAt();&lt;/code&gt; comes to the rescue xD ! Yes, it &lt;strong&gt;&lt;em&gt;shortens&lt;/em&gt;&lt;/strong&gt; the code and is much*&lt;em&gt;_ cleaner_&lt;/em&gt;*. It extracts the first character from the input entered by the user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnq6tuick031pzojprnwk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnq6tuick031pzojprnwk.png" alt="Image description" width="381" height="36"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whereas in &lt;code&gt;ch.charAt();&lt;/code&gt; you need to define string. If you want clarity or to &lt;strong&gt;&lt;em&gt;reuse&lt;/em&gt;&lt;/strong&gt; the string, then this method is preferable. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4hd7xpb6ju3o2f8r9mp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4hd7xpb6ju3o2f8r9mp.png" alt="Image description" width="312" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Conclusion&lt;/u&gt;:- Both does the same work i.e, both are used for extracting the first character. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus Tip&lt;/strong&gt; - ch.charAt(0) is often used to extract the first character, but in problems like 'finding vowels' we use .charAt(i) inside the loop in order to get our desired answer. &lt;/p&gt;

&lt;p&gt;THANKYOU FOR READING &amp;lt;3 &lt;/p&gt;

</description>
      <category>java</category>
    </item>
  </channel>
</rss>
