Java String Methods With Examples ?

java dev.to

trim() Removes extra spaces only at the beginning and end. Example: String s=" Admin123 "; System.out.println(s.trim()); // output:"Admin123" 2.equalsIgnoreCase() Compares two strings ignoring uppercase/lowercase. Example: "Vijay".equalsIgnoreCase("vijay"); // true 3.equals() vs == == checks memory reference(same object or not). equals() checks actual content/value. Example: String s1="java"; String s2=new String("java"); s1==s2 // output

Read Full Tutorial open_in_new
arrow_back Back to Tutorials