• 05 October

    Java BigDecimal to String

    In this post, we will see how to convert BigDecimal to String in java. There are many ways to convert BigDecimal to String in java. Some of them are: Using toString() Using String.valueOf() toString method You can simply use BigDecimal’s toString method to convert BigDecimal to String. [crayon-6a2a04fe46eb8523744523/] When you run above program, you will […]

  • 05 October

    Java String to BigDecimal

    In this post, we will see how to convert String to BigDecimal in java. It is very simple to convert String to BigDecimal in java. You can simply use BigDecimal ‘s String based constructor to do it. [crayon-6a2a04fe4d2ac617994565/] Above constructor convert String representation of BigDecimal to BigDecimal Let’s see this with the help of example: [crayon-6a2a04fe4d2b5650521326/] […]

  • 28 September

    Java String Replace

    Java String replace method replaces all occurrences of old char to new char or old CharSequence to new CharSequence and return new String. If there is nothing to replace in the String, it will return same String. Let’s say you need to convert "Java2blog" to "JavaTwoblog", you can simply use below syntax. [crayon-6a2a04fe4e771998018086/] Syntax There […]

  • 25 September

    List vs ArrayList in java

    In this post, we will see the difference between List and ArrayList in Java. List is an interface where ArrayList is concrete implementation, so List is more generic than ArrayList. You can instance an ArrayList in below two ways.You might have seen this code before. [crayon-6a2a04fe4fa68284146497/] If you use 1st way, you can change the […]

  • 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-6a2a04fe5095c854082206/] 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-6a2a04fe51d1b094190505/] 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 […]

  • Java Runnable
    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-6a2a04fe5af24418758245/] Create a main method named EmployeeReflectionMain.java. [crayon-6a2a04fe5af30892269623/] 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 […]