java - Calculatewith String of android -


this question has answer here:

i have

string id = "1"; string id2 = " 5"; 

how can calculate

string sum = id + id2 + "2"; 

how can sum , give result = 8

here relevant documentation, (oracle). need call integer.parseint("num"), make code work. should this:

int sum = integer.parseint(id) + integer.parseint(id2) + integer.parseint("2"); 

running outputting value using system.out.println(), get:

8 

Comments