Recent Posts

6 Ways To Use forEach in Java

To use for each in Java, you need to use the syntax like [crayon-614626216a3fa311565124/] Let's have a look at some more examples of forEach in Java.   1. forEach and list Using forEach, you can...

How to convert float to int in Java?

You can convert a float to an int in Java by using the round method Math.round(float): [crayon-61462621701f8778635985/] The method rounds the float to the closest int value. Other methods that you...

Initialize String[] in Java

To initialize String[] you can do: [crayon-614626216f2b3587508905/] More details are given below. Declaration vs Initialization Let's consider the array...

Java Sorting Map by key

To have a sorted map by key in Java you can use the TreeMap. It guarantees the natural order. You can use it like this: [crayon-614626216fcbf668321793/] For more details read the following...

How to get file extension in Java?

Simple Java parser If you want to get a file extension from the file path you can try this code: [crayon-614626216ccb9391086717/] The fileName is a variable which contains the name of your...