java - How to select particular values out of a string and turn them into an integer -
i'm using scanner obtain string containing x , y coordinate in form of x,y saved string xy1, how numbers of x , y can make int x1 equal x , int y1 equal y ignoring ","
if you're sure there's comma inside string, , 2 parts integers :
string xy1 = "123,4567"; string[] integers = xy1.split(","); int x1 = integer.valueof(integers[0]); int y1 = integer.valueof(integers[1]); system.out.println(x1 + " " + y1);
it outputs
123 4567
Comments
Post a Comment