Floating point manipulation in Java
Hi All,
Today, I am writing on a very interesting topic “How floating points are handled in java in JAVA?” Have you ever tried multiplying any two double like:
0.1*0.4
what do you expect the output should be? 0.04? No, that’s not the case, its 0.04000000000000001 crazy 😀
The reason why it is happening is the way double are handled in JAVA. So, to make it easy let us consider above example and understand step by step how double is handled and how JVM managed to give this output.
All floating numbers in Java follow IEEE 754 Double-precision floating-point format.
Internal Working of HashMap
Hi All,
This is the most popular question in interviews and definitely an important collection to understand. So, starting with the internal working of HashMap, I will be covering below concepts:
1) Hashing
2) Bucketing
3) Collision
4) Rehashing
Singleton in Java
When it comes to singleton, it is one of the most frequently asked Java question. There are multiple ways to ensure singleton behavior in multi-threaded environment like
-
- Making a variable public static final
- Making a synchronized getInstance method
- Double checked getInstance method
- Using Enums
Bit Operations in JAVA
Java supports multiple bit operations like :
- OR ( | )
- AND ( & )
- XOR ( ^ )
- Left Shift ( << )
- Right Shift ( >> )
- Unsigned Right Shift ( >>> )
- Complement ( ! )