Difference Between List, Set and Map in Java

List vs Set vs Map

1. Overview List, Set and Map in java are the most used interfaces of the collection framework. Collection framework has several interfaces and classes which are widely used in most java application. For storing data in collections, List, Set and Map are most often used interfaces. A difference between these interfaces is one of the … [Read more…]

Like this post? Don’t forget to share it!

Binary Search

Binary search example

Problem We have sorted array of some elements, and we have to find index of given element using Binary search (better than O(n) time complexity). Solution Here we are going to use Binary Search.  We can have two cases : Element exists in given array Element does not exist in given array Element exists in … [Read more…]

Like this post? Don’t forget to share it!

Comparison method violates its general contract!

Comparison method violates its general contract, error can be very painful to debug. I recently encountered this issue in one of the production servers and it was only sometimes the error was thrown. Here I would discuss some cases that can lead to such an error. Stacktrace Possible Coding Mistakes Example 1: In the below … [Read more…]

Like this post? Don’t forget to share it!

Static and Default Methods in Interface – Java 8

Introduction Java 8 introduces concept of “Default Methods” and “Static Methods” for interfaces, which allows developers to enhance existing interface used in their applications without breaking prior implementations of that interface. “Default Methods” and “Static Methods” are one of new features of Java 8 which is used extensively in core Java framework packages especially in collections. … [Read more…]

Like this post? Don’t forget to share it!

Java 9 new features

Java 9 is scheduled to be released in July 2017.  The Feature Extension Complete milestone was achieved in late December,. We will have a look at the new features in Java 9. Java 9 Features Module System (Jigsaw Project) JShell Collection Factory methods Private Methods in Interfaces Reactive Streams Multi Resolution Images API Process API … [Read more…]

Like this post? Don’t forget to share it!

Java 8 new features

In this article we are going to discuss the most important features of Java 8.  I would be discussing these features with examples. Functional Interfaces Functional interfaces are interfaces with exactly one method. They can have an annotation with @FunctionalInterface. A very good example of Function Interface is that of the Comparable. It has exactly … [Read more…]

Like this post? Don’t forget to share it!

Java Generics interview questions

Java Generics concepts

Here is a list interview questions that may be asked in interviews. Java Generics as a feature is one of the most controversial features added to Java Language. As a programmer, it is very important that the basic concepts of Generics should be very clear.  I have prepared a list of basic interview questions that … [Read more…]

Like this post? Don’t forget to share it!

RESTful Web Service interview questions

Restful API Questions What is REST? REST stands for Representational State Transfer. It is an architectural style of client-server application What are the constraints for REST architectural style? REST architectural style describes six contraints: Uniform Interface Stateless Cacheable Client-Server Layered System Code on Demand – Optional What is Uniform Interface? Uniform interface constraint defines the interface between … [Read more…]

Like this post? Don’t forget to share it!

External DTD: Failed to read external DTD ‘.dtd’, because ‘file’ access is not allowed due to restriction set by the accessExternalDTD property

[org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 36; External DTD: Failed to read external DTD ‘Custom.dtd’, because ‘file’ access is not allowed due to restriction set by the accessExternalDTD property.] Stacktrace Solution Add the following property to your vm arguments.

Like this post? Don’t forget to share it!

Top Java Hibernate interview questions

orm

In this article, I will be listing the frequently asked interview questions on hibernate in java application. These questions are collected from real interviews. All these questions check whether a candidate has basic knowledge of the hibernate. 1)  What’s ORM? Object-Relational Mapping (ORM) is a technique that lets you query and manipulate data from a … [Read more…]

Like this post? Don’t forget to share it!