Convert long to String
In this chapter you will learn:
Convert long value to string
Converting long
value to string
is easy with the help of the following methods.
String toString()
returns a String object representing this Long's value.static String toString(long i)
returns a String object representing the specified long.static String toString(long i, int radix)
returns a string representation of the argument i in the radix.
The following code converts long value to string. Pay attention to the second conversion since it specifies the radix.
public class Main {
public static void main(String[] args) {
System.out.println(Long.toString(10));
System.out.println(Long.toString(10,8));
}// jav a 2 s . c o m
}
The output:
Next chapter...
What you will learn in the next chapter:
- What is Java float type
- How to create float literals
- How to Create a Float object
- How to tell if a float is infinite or finite
- How to convert float value to int bits
Home » Java Tutorial » Primitive Data Types