Grails Cookbook - A collection of tutorials and examples

Convert Java Integer To Fixed Length String

There are situations where you want to convert a Java Integer to Fixed Length String. This is typical when we want to align Strings for visual effects, or some formatting required by the next system that will consume the output. We will show how to convert numbers to fixed length String in this post.

Java Split String Into ArrayList

There is a method that splits a String into an array of substrings given a specific delimiter, and this is the Java split() method. Converting a Java String into ArrayList using this method is essential and can be useful in many cases. Let's observe and study the given examples below for a deeper understanding.

Split String Into Array Of Integers in Java

Remember that the String.split() method splits a String into an array of substrings given a specific delimter. Each susbtring represents a number, which can be converted into an array of integer.

Java String Split Count

Just a reminder that the Java String.split() method is used to split a String to make an array of substrings through a specific delimeter. This topic will discuss on how the system will count the substrings created from the split method. Study and observe the written examples below:

Java String Split Newline

There are cases in which new line is used as a delimiter to split a java string. An example would be, when it is used to load the contents of a text document to a String if you want to break it line by ...

Double To String With 2 Decimal Places In Java

We will now discuss how to convert Java Double To String using 2 Decimal Places, and what are the methods and parameters that can help you acquire it. Although with that knowledge, an integer becomes an number if there's a separator that can describe what's it for. For example, 1234 is 12.34 if we put a dollar sign and separate it with a decimal point. Another example is when we put a comma separator to make it $1,234.00. In this topic, we will explore the details and process of converting a double to string with 2 decimal places. Check out the written examples below.

Double To String Without Exponential Scientific Notation in Java

What we will discuss in this topic is another data type which is called double. A good advantage from this data type is its conveniency and precision when it comes to dealing with numbers that are not whole. Although sometimes, when we try to convert a Double variable to a String, we get answers that are in exponential or scientific notation form. Check out below some examples of the process of converting Java double to string without exponential scientific notation in the Java Programming Language.

Maximum Value of Integer in Java

We've discussed in the previous post that an integer is a data type in Java, and we've determined that it's one of the main tools to use in calculations. Although with this information, it's necessary to remember that integers do not have a random large value, the Java Integer Maximum Value is 2,147,483,647. Check out below for more details.

Maximum Value of Long in Java

In Java, the data type integer is commonly used to calculate numbers. An integer with bigger range of values is efficient for some programs. Which will bring us to bits, an integer can only hold 32 bits whereas Java Long is capable of holding 64 bits. Now come to think of it, when you're creating a program that's required an integer exceeding 32 bits, you would realize Java Long is more effective to utilize. Understand that even though Java Long has bigger capacity than an integer, it still has a boundary limit for maximum value which is 9,223,372,036,854,775,807.

Check If String Contains Substringin Java

In Java, we can confirm if one String holds a specific substring. For example, we would like to check if the substring "rhapsody" is in the String "Bohemian rhapsody movie". Check out the examples on how to use Java String's contains method.