I have a question about optimization of my code (which works but is too slow...). I am reading an input in a form
X1 Y1 X2 Y2 etc
where Xi,
You could use regex to check if the value is numerical and then convert to integer:
if(st.nextToken().matches("^[0-9]+$")) { int x = Integer.parseInt(st.nextToken()); }