If you run your program with points like (0, 0) and (0, 4), your slope will be undefined. Java has a special keyword, NaN, for undefined values.
If you like, you could change your script to check whether double slope is NaN; if it is, print a more-understandable error message (e.g. "sorry, that slope is undefined") so your users don't have to figure out what NaN means.