Home » Java Basics » String


Java String to Date Example

Java gives us the capability to convert String to Date. This can be done through DateFormat and SimpleDateFormat classes, where the last class is a subclass of the first one. It is worth to mention that DateFormat is not thread-safe, so it is recommended to create different instances for each thread. In this example we will show you how to ...

Read More »

Java String to char Example

String to char conversion is a very simple procedure in Java. This process is useful when we want to use char format instead of strings in our applications, for instance in the arguments in command line. In this example we are going to show you how to parse a String to character(s). 1. Example of String to char conversion Create ...

Read More »

Java String to Float Example

float is a frequently used data type of 32-bit and it represents decimal numbers. The main difference from double is that it requires smaller size in memory but in some situations (big numbers) doesn’t represent the accurate number. A commonly used procedure in Java is the convertion from string to float. In this example we shall show you all the ...

Read More »

Java string to long Example

Long class forms the primitive type long, which can represent an integer number of 32 bits (2^32). A very common procedure in Java programming is the conversion of String to Long. As you can expect, in this example we are going to show how to convert a string to long in every possible way.         1. Syntax ...

Read More »

String to Double Java Example

In this article, we will show you how to convert string to double in java. String to Double conversion in Java is a frequent procedure because both data types are commonly used. As you can imagine in this example we are going to show all the possible ways of converting String object to Double object. 1. Syntax of the convert ...

Read More »

Substring Java Example

In this post, we feature a comprehensive Substring Java Example. We will show how to use Java String substring() API method. 1. Syntax substring() method can be expressed in two ways: String substring(int start, int end)String substring(int start) 2. Parameters start This parameter is mandatory and it specifies the starting position of the extracted string. Note that first character of string ...

Read More »