Java String Methods for Efficient Text Manipulation

🚀 Day 22 of Learning Java 📘 Built-in Methods in Strings Today, I explored some important String methods in Java that make text manipulation easier and more efficient. 🔹 Key Methods Covered: ✔️ "length()" – Returns the length of the string ✔️ "charAt(index)" – Returns character at given index ✔️ "toLowerCase()" – Converts string to lowercase ✔️ "toUpperCase()" – Converts string to uppercase ✔️ "indexOf()" – Finds first occurrence of a character ✔️ "lastIndexOf()" – Finds last occurrence of a character ✔️ "startsWith()" – Checks starting characters ✔️ "endsWith()" – Checks ending characters ✔️ "equals()" – Compares two strings (case-sensitive) ✔️ "equalsIgnoreCase()" – Compares without case sensitivity ✔️ "replace()" – Replaces characters in string ✔️ "substring()" – Extracts part of string ✔️ "split()" – Splits string into array ✔️ "trim()" – Removes extra spaces ✔️ "compareTo()" – Compares strings lexicographically 💻 Example Code: String s = "TapAcademy"; System.out.println(s.length()); System.out.println(s.charAt(3)); System.out.println(s.toUpperCase()); System.out.println(s.toLowerCase()); System.out.println(s.indexOf('A')); System.out.println(s.substring(3,7)); 🎯 What I Learned: ✨ Strings are immutable in Java ✨ Built-in methods simplify coding ✨ Very useful for real-world applications #Java #CodingJourney #100DaysOfCode #Programming #Learning #JavaDeveloper #Tech

  • text

To view or add a comment, sign in

Explore content categories