New Date and Time API in Java 8
Date and Time API in Java prior to Java 8 always scare the ordinary developers due to inadequate support for the date and time use cases. Before Java 8, the classes (such as java.util.Date and SimpleDateFormatter) aren’t thread-safe, leading to potential concurrency issues for user which made…
11 Ways to Convert InputStream to String in Java
As we discussed earlier about Java I/O in Decorator Design Pattern. Java I/O often results in a large number of small classes that can be overwhelmed to developer trying to use the API. In this article we are going to see 11 ways to convert Java…
What Is An Abstract Class In Java?
Let’s see what is an abstract class in Java. Consider below hierarchy of object creation for mobile manufacturing company. If company wants to create new model of any device (any of sub class type), then it can be created using new object instantiation. It makes…
Polymorphism in Java
The word ‘Polymorphism in Java’ literally means ‘a state of having many shapes’ or ‘the capacity to take on different forms’. An important example of polymorphism is how a parent class refers to a child class object. In fact, any object that satisfies more than…
Understanding Inheritance in Java
Let’s try understanding inheritance in Java – On high level, when we design using inheritance. We put the common code in class and then tell other specific classes(more abstract) that common code is their super class. When one class inherits from another class i.e., the…
How To Edit Class File From A JAR File?
Editing class file from a JAR file can also be called as patching a Java executable (Jar files) without knowing the source code. Let’s see how to edit class file from a JAR file using easy way of patching the Java executable file. Methods (Method…
Comparing ArrayList to a Regular Array
Let’s see Comparing ArrayList to a Regular Array, 1. A plain old array has to know its size at the time it’s created But for ArrayList, you just make an object of type ArrayList. Everytime, it never needs to know how big it should be,…
What is Encapsulation in Java?
Let’s see, What is Encapsulation in Java? Encapsulation is like creating a security layer for your instance variables rather than exposing it naked to the world. Hope you would know about private, public access modifiers. Encapsulation is going to use private, public access modifiers to implement…
Java follows Pass By Value as Parameter Passing Mechanism
Java follows Pass by Value and not Pass by Reference for parameter passing mechanism. While talking about pass by value and pass by reference, first we should understand what is pass by value and pass by reference and then we can jump into example of pass by…
Difference between Local and Instance variable in Java
What is the difference between Local and Instance variable in Java? Instance variable are declared inside a class but not within a method Instance variables always get a default value. If you don’t explicitly public class AddressBook { String firstName; String lastName; String phoneNumber; }…