Core java
- 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
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 […]
- 27 October
How to fix illegal start of expression error in java
In this post, we will see how to fix "illegal start of expression" in java. You will get this error while using javac command in command prompt. In eclipse or any other ide, it will give you more helpful compile time error. There can be multiple reasons for getting this error. Using private, public or […]
- 27 October
Count number of words in a string
In this post, we will see how to find number of words in a String. Problem Find the number of words in a String. For example: There are 6 words in below String welcome to java tutorial on Java2blog Algorithm The algorithm will be very simple. Initialize count with 1 as if there are no […]
- 24 October
Java 8 – java.util.function.Function example
In this post, we will see about java.util.function.Function functional interface. java.util.function.Function is part of java.util.function package. There are some inbuilt functional interfaces in java.util.function which you can use if functional interface matches with your requirement. java.util.function.Function is a functional interface which takes input single argument T and returns result R. It has an abstract method as below. […]
- 17 October
Java 8 Stream of example
In this post, we will see about Java 8 Stream‘s of method example. stream‘s of method is static method and used to create stream of given type. For example: [crayon-6742eed8626eb122203092/] There are two overloaded version of Stream’s of method. 1) static <T> Stream<T> of(T… values) Returns a sequential ordered stream whose elements are the specified values. […]
- 17 October
Java Stream collect to array
In this post, we will see how to collect any Java 8 Stream to array. There are many ways to do it but I am going to show easiest way. You can simply use toArray(IntFunction<A[]> generator).This generator function takes size as input and creates new array of that size. Convert Steam to Array Let’s understand […]