Category Archives for Java

Convert String to int in Java

Convert String to int in Java There are few ways to Convert String to int in Java. Below are few of popular ways for converting String to int Integer.parseInt() Integer.valueOf() 1.  Integer.parseInt() Examples Integer.ParseInt()  will return an int primitive value.If efficiency is your concern and you only need primitive value, then using Integer.ParseInt()  is the best option. […]

Continue reading

Java Comparable vs Comparator

Java Comparable vs Comparator In this articles we will discuss Java Comparable vs Comparator, often people have  lots of questions when it comes to Java Comparable vs Comparator What is Comparable and what is Comparator in Java How do we use them What is the difference between Comparable and Comparator? When we should use Comparable vs […]

Continue reading

BigDecimal equals versus compareTo

While going through compareTo(T o) method in the Comparable interface, I came across a very interesting finding of BigDecimal equals versus compareTo and though about sharing about it. Usually, we require that two objects are equal if and only if they are compared as same For BigDecimal things are really interesting when we check both […]

Continue reading
1 13 14 15