[Go to site: main page, start]

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

ISC Class11 Java String Functions Notes-1

The document provides notes on various string functions in Java for ISC Class 11, detailing their purpose and usage with examples. Functions include length(), charAt(), substring(), indexOf(), equals(), and more, each demonstrating how to manipulate and analyze strings. It serves as a concise reference for students learning Java string methods.

Uploaded by

berojgar06
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)
3 views2 pages

ISC Class11 Java String Functions Notes-1

The document provides notes on various string functions in Java for ISC Class 11, detailing their purpose and usage with examples. Functions include length(), charAt(), substring(), indexOf(), equals(), and more, each demonstrating how to manipulate and analyze strings. It serves as a concise reference for students learning Java string methods.

Uploaded by

berojgar06
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

ISC Class 11 Java - String Functions Notes

length()
Returns total number of characters.
Example: String s='COMPUTER'; [Link](); Output: 8
charAt(index)
Returns character at given index.
Example: String s='JAVA'; [Link](2); Output: V
substring(beginIndex)
Returns substring from index to end.
Example: 'COMPUTER'.substring(3)=PUTER
substring(begin,end)
Returns begin to end-1.
Example: 'COMPUTER'.substring(2,6)=MPUT
indexOf()
First occurrence.
Example: 'BANANA'.indexOf('A')=1
lastIndexOf()
Last occurrence.
Example: 'BANANA'.lastIndexOf('A')=5
equals()
Case-sensitive comparison.
Example: 'Java'.equals('Java')=true
equalsIgnoreCase()
Ignores case.
Example: 'Java'.equalsIgnoreCase('JAVA')=true
compareTo()
Lexicographic comparison.
Example: [Link](Banana)=negative
compareToIgnoreCase()
Lexicographic ignoring case.
Example: [Link](apple)=0
concat()
Joins strings.
Example: 'Hello '.concat('World')
toUpperCase()
Uppercase.
Example: computer -> COMPUTER
toLowerCase()
Lowercase.
Example: JAVA -> java
trim()
Removes leading/trailing spaces.
Example: ' JAVA ' -> JAVA
replace()
Replace all chars/substrings.
Example: APPLE -> ABBLE
replaceFirst()
Replace first occurrence.
Example: one one->two one
replaceAll()
Replace all occurrences.
Example: one one->two two
startsWith()
Checks prefix.
Example: Computer startsWith Com=true
endsWith()
Checks suffix.
Example: Computer endsWith ter=true
contains()
Checks substring.
Example: Contains Science=true
isEmpty()
Checks empty string.
Example: ''.isEmpty()=true
split()
Splits by delimiter.
Example: Red,Blue -> Red Blue
valueOf()
Converts value to String.
Example: 125->'125'
intern()
Returns pooled string.
Example: new String('Java').intern()
toCharArray()
Converts to char array.
Example: JAVA -> J A V A

You might also like