Understand limitations of floating point representations.Never check for equality with ==. Instead, check if the difference is less than an epsilon value.
public class Line{
static double epsilon=0.000001;
public double slope;
public double yintersect;
public Line(double s, double y){
slope=s;
yintersect=y;
}
public boolean intersect(Line line2){
return Math.abs(slope-line2.slope)>epsilon||
Math.abs(yintersect-line2.yintersect)<epsilon;
}
}