0% found this document useful (0 votes)
5 views1 page

Java String Character CheatSheet

This cheat sheet outlines important Java String and Character methods, including their functionalities such as length, substring, and character checks. It highlights commonly used methods for coding interviews, emphasizing their significance in practical applications. The document serves as a quick reference for developers working with strings and characters in Java.

Uploaded by

Tamojoy Chanda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Java String Character CheatSheet

This cheat sheet outlines important Java String and Character methods, including their functionalities such as length, substring, and character checks. It highlights commonly used methods for coding interviews, emphasizing their significance in practical applications. The document serves as a quick reference for developers working with strings and characters in Java.

Uploaded by

Tamojoy Chanda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java String & Character Methods Cheat Sheet

Important String Methods

• length() → Returns number of characters


• charAt(index) → Returns character at index
• substring(begin, end) → Extracts part of string
• equals(str) → Compares values (case-sensitive)
• equalsIgnoreCase(str) → Compares ignoring case
• compareTo(str) → Lexicographic comparison
• toLowerCase() / toUpperCase() → Change case
• trim() → Removes leading/trailing spaces
• indexOf(str) → First occurrence index
• lastIndexOf(str) → Last occurrence index
• contains(str) → Checks substring presence
• replace(old, new) → Replaces characters
• replaceAll(regex, repl) → Replace using regex
• split(regex) → Splits into array
• startsWith(prefix) → Checks starting text
• endsWith(suffix) → Checks ending text
• isEmpty() → Checks if string is empty
• valueOf(data) → Converts data to String

Important Character Methods (Character class)

• [Link](ch) → Checks if letter


• [Link](ch) → Checks if digit
• [Link](ch) → Checks if space
• [Link](ch) → Checks uppercase
• [Link](ch) → Checks lowercase
• [Link](ch) → Converts to uppercase
• [Link](ch) → Converts to lowercase
• [Link](ch) → Gets numeric value

Interview Tip:

Most commonly used methods in coding interviews: length(), charAt(), substring(), equals(),
indexOf(), split(), replace(), [Link](), [Link]().

You might also like