How to change String to long

Asked 2 years ago, Updated 2 years ago, 20 views

It's a simple question. How do I change the string to long?

java

2022-09-21 17:11

1 Answers

Long.parseLong("0", 10)        // returns 0L
 Long.parseLong("473", 10)      // returns 473L
 Long.parseLong("-0", 10)       // returns 0L
 Long.parseLong("-FF", 16)      // returns -255L
 Long.parseLong("1100110", 2)   // returns 102L
 Long.parseLong("99", 8)        // throws a NumberFormatException
 Long.parseLong("Hazelnut", 10) // throws a NumberFormatException
 Long.parseLong("Hazelnut", 36) // returns 1356099454469L


2022-09-21 17:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.