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

String

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

String

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

Here’s a list of commonly used String methods in Java — just the method names with a

quick note:

🔤 Java String Methods

1. length() – returns length of the string


2. charAt(int index) – returns character at given index
3. substring(int beginIndex)
4. substring(int beginIndex, int endIndex)
5. toLowerCase()
6. toUpperCase()
7. trim() – removes leading/trailing spaces
8. equals(String another) – checks exact match
9. equalsIgnoreCase(String another)
10. `compareTo

✅ 1. Lambda Expressions
List<String> list = Arrays.asList("a", "b", "c");
list.forEach(s -> System.out.println(s));

✅ 2. Functional Interfaces
@FunctionalInterface
interface MyFunc {
void sayHello();
}
MyFunc f = () -> System.out.println("Hello");
f.sayHello();

✅ 3. Streams API
List<Integer> nums = Arrays.asList(1, 2, 3, 4, 5);
nums.stream().filter(n -> n % 2 == 0).forEach(System.out::println);

✅ 4. Default Methods in Interfaces


interface A {
default void show() {
System.out.println("Default method");
}
}

You might also like