0% found this document useful (0 votes)
5 views2 pages

Java String Character Detailed CheatSheet

This document is a cheat sheet detailing important Java String and Character methods, including examples for each method. Key String methods highlighted include length(), charAt(), substring(), equals(), indexOf(), contains(), replace(), split(), toUpperCase(), toLowerCase(), and trim. Important Character methods discussed are isLetter(), isDigit(), isUpperCase(), isLowerCase(), toUpperCase(), toLowerCase(), and getNumericValue, with a focus on methods most relevant for coding interviews.

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 views2 pages

Java String Character Detailed CheatSheet

This document is a cheat sheet detailing important Java String and Character methods, including examples for each method. Key String methods highlighted include length(), charAt(), substring(), equals(), indexOf(), contains(), replace(), split(), toUpperCase(), toLowerCase(), and trim. Important Character methods discussed are isLetter(), isDigit(), isUpperCase(), isLowerCase(), toUpperCase(), toLowerCase(), and getNumericValue, with a focus on methods most relevant for coding interviews.

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 – Detailed Cheat

Sheet

1. Important String Methods (with Examples)

length()
String s = "Hello";
[Link]([Link]()); // 5

charAt(index)
String s = "Hello";
[Link]([Link](1)); // 'e'

substring(begin, end)
String s = "Programming";
[Link]([Link](0, 6)); // "Progra"

equals() vs ==
String a = new String("Java");
String b = new String("Java");
[Link]([Link](b)); // true
[Link](a == b); // false

indexOf()
String s = "banana";
[Link]([Link]("na")); // 2

contains()
String s = "Hello World";
[Link]([Link]("World")); // true

replace()
String s = "apple";
[Link]([Link]('p','b')); // "abble"

split()
String s = "one,two,three";
String[] arr = [Link](",");
[Link](arr[1]); // "two"

toUpperCase() / toLowerCase()
String s = "Java";
[Link]([Link]()); // "JAVA"
[Link]([Link]()); // "java"

trim()
String s = " hello ";
[Link]([Link]()); // "hello"

2. Important Character Methods (Character Class)

isLetter()
char ch = 'A';
[Link]([Link](ch)); // true

isDigit()
char ch = '9';
[Link]([Link](ch)); // true

isUpperCase()
char ch = 'A';
[Link]([Link](ch)); // true

isLowerCase()
char ch = 'a';
[Link]([Link](ch)); // true

toUpperCase() / toLowerCase()
char ch = 'a';
[Link]([Link](ch)); // 'A'

getNumericValue()
char ch = '7';
[Link]([Link](ch)); // 7

Interview Focus:

Most important for coding interviews: length(), charAt(), substring(), equals(), indexOf(), split(),
replace(), [Link](), [Link]().

You might also like