isEmpty, startswith and endsWith

isEmpty This method is used to check whether string has any characters in it or its empty string. It returns true if length of a string is zero and false otherwise. Method signature public boolean isEmpty() public boolean isEmpty() Example public class StringEmptyExample{   public static void main(String args[]){   String s1="";   String s2="java"; […]

Share this article on

String intern()

Intern() method available in String class is used to return the string from the String constant pool. This will reduce the problem of string duplicates in Java. Whenever we call intern() method of String on any string object, it first checks whether same string is already available in string pool. If it’s available in pool, […]

Share this article on
< Previous Next >