Unlike maths-on-paper
notation, most programming languages (Java included) need a *
sign to do multiplication. Your distance calculation should therefore read:
distance = Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
Or alternatively:
distance = Math.sqrt(Math.pow((x1-x2), 2) + Math.pow((y1-y2), 2));