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 »

Java String to Double Example

String to Double conversion 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 operations First of all, in order to convert a string to double, ...

Read More »

Substring Java Example

In this 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 is at index 0 not ...

Read More »