Equals() and hashCode() method in Java

Object Equality When it comes to Java ,there are two types of Object equality ,reference equality and object equality. Reference Equality Two references that refer to the same object on the heap are considered equal.If you want to check if two references are referring to the same object using the ‘==’ operator. The ‘==’ operator […]

How HashMap works in Java1.8?

HashMap is a hash table implementation of Map interface in Java. A map contains a collection of key-value pairs where key maps to the value.HashMap permits null values and null keys and it doesn’t permit duplicate keys.It is unordered so it doesn’t guarantee that the order will remain constant with time. Hashmap provides constant time […]

How to resolve package com.sun.image.codec.jpeg does not exist?

Sometimes the java project (usually a lower version of Java (1.6 or lower)) results in the following compilation error:- INFO] Compiling 106 source files to /Users/JavaProject/src/java/web/target/classes [INFO] ————————————————————- [ERROR] COMPILATION ERROR : [INFO] ————————————————————- [ERROR] /Users/JavaProject//src/java/web/main/java/net/esi/ppc/presentation/service/CaptchaImageGenerator.java:[24,31] error: package com.sun.image.codec.jpeg does not exist [ERROR] /Users/JavaProject//src/java/web/main/java/net/esi/ppc/presentation/service/CaptchaImageGenerator.java:[25,31] error: package com.sun.image.codec.jpeg does not exist To resolve this issue you […]

Default Methods In Java

Default methods allows us to add new functionality to new or existing interfaces without breaking the existing functionality of legacy code. Prior to Java 1.8 interfaces did not allow default interfaces and it was very difficult to modify an existing interface without impacting the class which implemented the interface.For instance if a new method is […]