HTML

Difference between a List and ArrayList Reference Variable in Java?

Someone who is just starting with Java programming language often has doubt about how we are storing an ArrayList object in List variable, what is the difference between List and ArrayList? or why not just store the ArrayList object in ArrayList variable just like we do for String, int, and other data types. Well, the main difference between List and ArrayList is that List is an interface while ArrayList is a class. Most importantly, it implements the List interface, which also means that ArrayList is a subtype of List interface. In Java or any object oriented language, super type of variable can store an object of subtype. This is known as Polymorphism because any virtual method will be executed from subclass only, even though they were called from super type. This is the beginning, now let's see those two questions as well.

How to Compare Two Dates in Java? Check If They Are Equal, Later or Earlier

There are multiple ways to compare two dates in Java, it also depends on upon what exactly comparison means. If you are looking to compare two dates to find out whether they are equal or not, then you can simply use equals() method of java.util.Date class. This method will return true if both dates are equal, precisely both thave same millisecond value. If you are looking to find out whether a date comes before or after another date then you have 3 choices, you can use compareTo() method of java.util.Date class, or you can use before() and after() method of Date class, or you can use before() and after() method of Calendar class. I suggest leveraging before() and after() method of Date class, they are more readable and easy to use.

Java - InstanceOf KeyWord Example and Tutorial

The Java programming language and JVM are full of hidden gems and even though I am using Java for more than a decade I still get surprised of features which I didn't know for quite some time e.g. shutdown hook, covariant method overriding, and JVM option to refresh DNS cache.  The instanceof operator is also one of the rarely known features of Java, It is used to check if an object is the instance of a particular Class or not. It returns true if the object is an instance of the class, otherwise, returns false. You might have seen usages of instanceof operator in Java while overriding equals() method. Since for checking equality of two instances, the first step is to verify whether they are the instance of the same object or not, you can use the instanceof operator there.

Top 10 Java 9 Tutorials and Courses - Best of Lot Must Read

It's been more than a couple of months since JDK 9 was launched and the new year is probably the best time to learn Java 9 and get yourself familiar with new features and enhancements on existing APIs. The highlight of JDK 9 release was Project Jigsaw or Module system. The Java 9 Platform Module System allows Java to move forward by modularizing the JDK as well as adding modules as first-class citizens to Java, but that's not the only thing to look forward, there are many small changes which are very useful in day-to-day coding. For me the static factory methods introduced in List, Set, and Map to create a immutable list, set and the map is the most interesting one. Along with several changes on Stream API and Optional class. Those are the ones, I will most likely to use as soon as we start with JDK 9.

10 Books for Coders of All levels - Must Read Best of Lot

Coding is one of the most important skills for programmers and if you want to survive as a programmer you must improve your coding skill. Gone are the days, when you can get a software development job without having you to write a single line of code and then somehow survives in the job by doing support, coordination, and other non-coding activities. Companies, both big and small are increasingly testing coding skills of candidates before hiring. It's very common for programmers to pass a coding test before a telephonic round of interview. Some of the companies even hire websites like HackerRank and others to check the coding skill of potential candidates, many others give candidates take home coding tests. In short, companies have a lot of focus on the coding skill of potential hires.

Top 50 Basic Core Java Interview Questions with Answers

If you are preparing for your next Core Java interview and looking for some common question to practice or check your knowledge then you have come to the right place. In this article, I'll share 50 Core Java Interview Questions from various companies. I have already discussed the answers to these questions in this blog or Javarevisited, so I have just put the link. First, you should try to answer it yourself and if you cannot then go to the link and find the answer. You can also compare your answer with mine and learn a few things here and there. In most of my interview post, I have also shared some common techniques to drive interview towards your comfort zone and how to leave a long-lasting impression on the interviewer, you can use those techniques to do well on your Java interviews.