java.lang

Java Character isUpperCase() Example

Java Character API comes with many methods to check the case of a letter – lowercase or uppercase. After checking, the character can be converted from lowercase to uppercase or uppercase to lowercase as per the need of the logic. Following is the method signature as defined in java.lang.Character class. public static boolean isUpperCase(char ch): …

Java Character isUpperCase() Example Read More »

Java Character isLowerCase() Example

Java Character API comes with many methods to check the case of a letter – lowercase or uppercase. After checking, the character can be converted from lowercase to uppercase or uppercase to lowercase as per the need of the logic. Following is the method signature as defined in java.lang.Character class. public static boolean isLowerCase(char ch): …

Java Character isLowerCase() Example Read More »

Java Character toString() Example

Java is a simple language to practice and develop more code in less time. All this is due to predefined API methods designers add in each version. Good examples are classes like String, Character, GregorianCalendar and LinkedList etc. They are designed as classes and methods are given to manipulate them. For example, addFirst() and addLast() …

Java Character toString() Example Read More »

Use equalsIgnoreCase() with Character objects

We have seen earlier comparing two Character objects with equals() method. It was case sensitive comparison. Infact, Character class does not have a method like equalsIgnoreCase(). But String has one. Apply a small technique to do case insensitive comparison with characters. Just convert both the characters in comparison either to uppercase or lowercase. For this …

Use equalsIgnoreCase() with Character objects Read More »

isEmpty() String Example

java.lang.String class comes with many methods to check the string characters are lowercase or uppercase, digit or letter etc. Now, isEmpty() method returns true if string does not contain any characters or string length() is zero. Following is the method signature. public boolean isEmpty(): Tests string contains data. If the length() returns 0, then isEmpty() …

isEmpty() String Example Read More »

Difference Math.rint() Math.round()

Difference Math.rint() Math.round() First find the preliminary difference of rint() and round() methods 1. System.out.println(Math.rint(2.50)); // prints 2.0 2. System.out.println(Math.round(2.50)); // prints 3 Let us study more: 1. With rint() a) 2.50 lies between 2.00 and 3.00. rint() returns the closest even double value. The rint(2.50) returns 2.0 b) 1.50 lies between 1.00 and 2.00. …

Difference Math.rint() Math.round() Read More »