How to convert an int to a formatted string in java

Using java.util.formatter

See the Formatter docs for other modifiers.

Read More

How to check If a String is an Integer in Java

Suppose we have the following problem. User input some value, how to check that this value is a String is an integer: 1. Check by Exception

Read More

Output data to excel file by template with jxls

Let’s assume we have a Java collection of Car objects that we want to output into Excel. The Car class may look like this

To use Jxls to output …

Read More

How to repeat string n times in java?

Suppose you have the string ‘qwe’ and you need to repeat string ‘n’ times. Here’s how to do it: Using java 8 stream api

Using String.format

Let us examine …

Read More

How to convert ‘ArrayList to String array in Java

Using Collection.toArray method First way to convert arraylist is to use built-in for every java collection method toArray(T[] ts) For example:

The toArray()  method without any argument returns Object[].  So you have …

Read More