Iterators are basically used to traverse over a set of objects one by one. Java supports two types of Iterators Fail Fast Iterator Fail Safe Iterator Fail Fast Iterator Fail fast iterator do not allow any modifications to a collection while iterating/traversing the collection.By modification I mean any updating, addition of elements in the collection.If […]
Category Archives: Technology
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 […]
Loops in Java
Loops in java are used to execute a set of statements repeatedly until a condition is satisfied or to iterate a collection of objects. There are 4 types of loop:- The basic for loop The enhanced for loop The while loop The do while loop The forEach loop The basic for loop The basic for […]