+ 1

How to convert datatypes in Java

Is it possible used to convert datatypes between each other in Java? Like in python? For example String to int, string to array, int to string... If so, How?

30th Jan 2020, 8:37 AM
Sofonias
Sofonias - avatar
3 Respostas
+ 3
String to int: String s = "42"; int num = Integer.parseInt(s); Int to String: int num = 42; String s = String.valueOf(num);
30th Jan 2020, 9:11 AM
r8w9
r8w9 - avatar
+ 2
r8w9 do the parseInt and valueOf methods require any libraries?
30th Jan 2020, 10:11 AM
Sofonias
Sofonias - avatar
+ 1
No.
30th Jan 2020, 11:13 AM
r8w9
r8w9 - avatar