Core java
- 15 May
Java LocalDateTime to Date
In this post, we will see how to convert LocalDateTime to Date. Java 8 has introduced a lot of new APIs for Date and time. There can be many ways to convert Java LocalDateTime to date. Using Instant object You can convert LocalDateTime to date using Instant object which we can from ZonedDateTime. Here is […]
- 09 May
FileNotFoundException in Java
In this post, we will see about FileNotFoundException in java. FileNotFoundException is thrown by constructors of FileInputStream, FileOutputStream, RandomAccessFile when file is not found on specified path. Exception can also be raised when file is inaccessible for some reason.For example: When you do not have proper permissions to read the files. FileNotFoundException is checked exception […]
- 04 May
How HashMap works in java
Most common interview questions are <code>How HashMap works in java</code>, “How get and put method of HashMap work internally”. Here I am trying to explain internal functionality with an easy example. [crayon-674265e51d014284736005-i/]Â is one of the most used Collections in java.Rather than going through theory, we will start with example first, so that you will […]
- 13 April
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
If you are getting below error while running the Maven build. No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? There are 3 ways to solve No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?. Eclipse maven […]
- 31 March
FizzBuzz program in java
In this post, we will see how to program FizzBuzz in java. Fizzbuzz is a fun game played generally by school children. It is simple game in which when your turn comes, you need to say the next number. So here are rules of the game: If number is divisible by 3, then you need […]
- 30 March
Implement isPrime method in java
In this post, we will implement isPrime method. isPrime method will take an integer as input and determine whether the number is prime or number. A prime number is a number which has only two divisors 1 and itself. To check if the number is prime or not, we need to see if it has any […]
- 30 March
java random number between 1 and 10
We have already seen random number generator in java.In this post, we will address specific query on how to generate random number between 1 to 10. Using random.nextInt() to generate random number between 1 and 10 We can simply use Random class’s nextInt() method to achieve this. As the documentation says, this method call returns "a […]
- 27 March
Could not find or load main class
In this post, we will discuss Could not find or load main class. Did you get this error before? If you have good amount of experience in Java programming or as a novice java developer, you might have encountered this error:Â Could not find or load main class. Before we understand about this error, let’s first […]
- 10 March
Print pyramid pattern: 1 3*2 4*5*6 pattern in java
In this post, we will see how to print the following pyramid pattern. Problem Input : n = 4 Output : 1 3*2 4*5*6 10*9*8*7Input : n = 5 Output : 1 3*2 4*5*6 10*9*8*7 11*12*13*14*15 Solution If you notice the pattern we need to print odd rows in increasing order and even rows in […]