In Java, String is an object that holds text. In apps that process text, String methods come in handy every single day. Usernames, emails, search keywords, messages, titles, content—all of it is a String.
java
public class Main {
public static void main(String[] args) {
String title = "Java Tutorial";
String email = "student@example.com";
System.out.println("Length: " + title.length());
System.out.println(title.toUpperCase());
System.out.println("Has @: " + email.contains("@"));
System.out.println("Domain starts at index: " + email.indexOf("example"));
}
}length() gives you the character count. toUpperCase() converts text to uppercase. contains() checks whether a piece of text is present, returning true/false. indexOf() returns the index where a piece of text first appears.
You should see
Length: 13 JAVA TUTORIAL Has @: true Domain starts at index: 8Real-world use
String methods are used in search boxes, login forms, formatting content titles, email checks, and cleaning up usernames.