Recent Posts

6 Ways To Use forEach in Java

To use for each in Java, you need to use the syntax like [crayon-6105a7c1018cb835523527/] 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-6105a7c107d8e156292432/] 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-6105a7c106eed810547772/] 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-6105a7c107838020102290/] 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-6105a7c104bd3623613867/] The fileName is a variable which contains the name of your...