[Java Basics] Conversion between Long and String types in java

1. Long type to String type

There are two ways to convert Long to String:
1: String str = String.valueOf(Long val);
2:String str = Long.toString(Long val);

Two, String type to Long type

There are two ways to convert String to Long:
1: Long L = Long.parseLong(String str);
The converted value is a Long packaging type.
2: long l = Long.ValueOf(String str);
The converted value is the long basic type

Note: Only numbers can be included in the string.

Guess you like

Origin blog.csdn.net/someday____/article/details/129283467