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?

general_bearbrand
  • 827
  • 5
  • 13
  • 29

1 Answers1

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
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249