• 04 November

    How to create list of lists in java

    In this posts, we will see how to create a list of lists in java. You can easily create a list of lists using below syntax List<ArrayList<String>> listOfLists = new ArrayList<ArrayList<String>>(); or ArrayList<ArrayList<String>> listOfLists = new ArrayList<ArrayList<String>>(); One of the Usecase This is generally useful when you are trying to read a CSV file and […]

  • 04 November

    Can we overload main method in java

    In this post, we will see about "Can we overload main method in java".This is one of the most asked Core java interview questions. Yes, we can overload main method in java but when you run your program, JVM will search for public static void main(String[] args) and execute that method. Overload main method in […]

  • 02 November

    Dynamic method dispatch in java

    In this post, we will about Dynamic method dispatch which is also referred as run time polymorphism. Dynamic Method Dispatch Dynamic method dispatch is a technique by which call to a overridden method is resolved at runtime, rather than compile time.When an overridden method is called by a reference, then which version of overridden method […]

  • 01 November

    Java DecimalFormat example

    In this post, we will see how to format a number using DecimalFormat in java. DecimalFormat DecimalFormat class is subclass of NumberFormat class and it is used to format numbers by using specify formatting pattern.We can format a number upto 2 decimal place,upto 3 decimal place, using comma to separate digits. Creating DecimalFormat object [crayon-662f6dd9b595a891289095/] […]

  • 29 October

    Can we override static method in java

    No, we can not override static method in java. Static methods are those which can be called without creating object of class,they are class level methods. On other hand,If subclass is having same method signature as base class then it is known as method overriding. Its execution decided at run time. Below are the reasons why […]

  • 28 October

    How to take input from user in java

    In this post, we will see how to take input from user in java. There are times when you want to take input from user and run program according to user input. There are many ways to take input from user and some of them are: Using Scanner Using BufferReader Using  Scanner class Scanner class […]

  • 28 October

    Could not reserve enough space for 2097152kb object heap

    In this post, we will see an error(Could not reserve enough space for 2097152kb object heap object heap) which you might have encountered while dealing with JVM.We will see how can we fix this issue. error occurred during initialization of vm could not reserve enough space for 2097152kb object heap is generally raised when Java […]

  • 28 October

    Error could not create the Java virtual machine in java

    In this post, we will about an error: Could not create the Java virtual machine in java. You can provide VM arguments to provide heap size for Java virtual machine. You can specify VM argument -Xms and -Xmx in form of KB, MB or GB. For example: Let’s say you want to specify maximum heap […]

  • 27 October

    How to fix class interface or enum expected error in java

    In this post, we will see how to fix "class interface or enum expected" error in java. There can be multiple reason for getting this error. Due to method outside class body This error you will generally get when you have accidentally put your method outside class body. Let’s see with the help of simple […]