"Exploring Java String Methods: substring, replace, trim, and more"

🧩 Day 12: String Methods in Java (In Depth) Today I explored some powerful built-in methods that make string handling efficient and flexible. These are the real tools behind text manipulation in Java! 💡 What I Learned Today substring(start, end) → Extracts part of a string replace(oldChar, newChar) → Replaces characters equalsIgnoreCase() → Compares strings ignoring case trim() → Removes extra spaces indexOf() → Finds position of a character or substring contains() → Checks if substring exists split() → Splits string into parts based on a delimiter 🧩 Example Code public class StringMethods {   public static void main(String[] args) {     String text = " Java Programming ";     System.out.println("Original: '" + text + "'");     System.out.println("Trimmed: '" + text.trim() + "'");     System.out.println("Substring: " + text.substring(2, 6));     System.out.println("Replace: " + text.replace("a", "@"));     System.out.println("Contains 'Java': " + text.contains("Java"));     System.out.println("Index of 'P': " + text.indexOf("P"));   } }

  • graphical user interface, application, Teams

To view or add a comment, sign in

Explore content categories