[Solved] Extract co ordinates from string [closed]


Method:

public static void main(String[] args) {
    String s = "(1,2)";
    System.out.println("x=" + s.substring(1, s.indexOf(",")));
    System.out.println("y=" + s.substring(s.indexOf(",")+1, s.length()-1));
}

Will give the following output:

x=1
y=2

This will even work, if the numbers have more than one digit.

0

solved Extract co ordinates from string [closed]