14

How to get value of an object and store it in variable int? In string I do this:

String k = s_extend.getValue().toString(); 

How about in int?

1
  • have you ever heard Integer.parseInt() ? Commented Dec 13, 2013 at 1:04

1 Answer 1

13

You can use Integer.valueOf() or Integer.parseInt(); unless there's more to your question that would be something like this -

public static void main(String[] args) { String str = "1"; int a = Integer.valueOf(str); // java.lang.Integer return(ed) int b = Integer.parseInt(str); // primitive (int) return(ed) System.out.printf("a = %d, b = %d\n", a, b); } 

On my machine, running this gives

a = 1, b = 1 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.