Core java
- 24 September
How to convert List to Set in java
In this post, we will see how to convert List to Set in java.We will convert ArrayList to HashSet. As HashSet does not allow duplicates, when you convert ArrayList to HashSet, all the duplicates will be discarded. You can simply use the constructor of HashSet to convert ArrayList to HashSet. [crayon-68c694cc57af3939279771/] Here is simple example: […]
- 24 September
BigDecimal compareTo
In this post,we will see about Bigdecimal‘s compareTo method.This method is used to compare two BigDecimals. Syntax [crayon-68c694cc57fd3054056379/] Return type CompareTo method returns -1,0,1 -1 : First BigDeicmal is less than second BigDecimal 0 : First BigDecimal is equal to second BigDecimal 1 : First BigDecimal is greater than second BigDecimal BigDecimal CompareTo example Let’s […]
- 24 September
Java Runnable example
In this post, we will see Java Runnable example. As you might know, there are two ways of creating threads in java. Extending thread class Implementing Runnable interface. As you can extend only one class in java, it is not possible to extend any other class if a class extends thread class.You can also implement […]
- 23 September
How to invoke method using reflection in java
In this post, we will see how to invoke the method using reflection in java. Let’s understand this with the help of the example. Create a class named Employee.java. We will invoke this class’s method using reflection. [crayon-68c694cc58345332648766/] Create a main method named EmployeeReflectionMain.java. [crayon-68c694cc5834c799138901/] When you run above program, you will get below output: […]
- 23 September
Java Reflection tutorial
Introduction Reflection, as we know from the common term, is an image of yourself or something else you see in a mirror or a mirrored surface. Java, being an object-oriented language draws heavily from real-life examples and so is the Reflection API of Java inspired from real life. In Java, the process of analyzing, viewing […]
- 22 September
Java program to Remove element from array
In this post, we will see how to remove an element from array in java. Unlike Arraylist,Java Arrays class does not provide any direct method to add or delete element. As Array is fixed size in nature, you can not shrink or grow it dynamically. You need to create new array and copy all elements […]
- 10 September
Top 30 Java 8 interview questions and answers
In this post, we will some important interview questions specifically on Java 8. Java has changed a lot over years and Java 8 has introduced many new features which you need to know when you are preparing for Java interview.  Here is a list of most asked Java 8 interview questions. 1)  What are […]
- 26 August
Copy Constructor in java
In this post, we will see about copy constructor in java. Copy constructor is the constructor which takes parameter as object of same class and copy each field of the class to the new object. Unlike C++, java does not provide default copy contructor. You need to create one, if you want to have copy […]
- 26 August
Java default constructor
In this post, we will see about Java default constructor. Default constructor is the no arg constructor which is inserted by compiler unless you provide any other constructor explicitly. You won’t able to see it as it is present in class file rather than source file. Is there any difference between no argument constructor and […]