For example, here are two ways:
Integer x = Integer.valueOf(str);
// or
int y = Integer.parseInt(str);
There is a slight difference between these methods: valueOf
returns a new or cached instance ofjava.lang.Integer
parseInt
returns primitiveint
.
No comments:
Post a Comment