Useful String functions and more

Java

StringBuilder

StringBuilder str = new StringBuilder();

str.append("Hello");
str.append("World");

System.out.println(str.toString());
HelloWorld

equals()

syntax

public boolean equals(Object anotherObject)

example

String myStr1 = "Hello";
String myStr2 = "World";

System.out.println("Hello".toLowerCase().equals("hello")); // Returns true
System.out.println(myStr1.equals(myStr2));                 //Returns false

compareTO()

join()

split()

more useful functions

Last updated

Was this helpful?