I was wondering how can I execute both of these exceptions in the same constructor. My program compiles fine, but it won't throw the exception for the second if statement.
public Segment(Point firstPoint, Point secondPoint) {
if(firstPoint == null || secondPoint == null)
throw new IllegalArgumentException("Cannot pass a null value");
if(firstPoint == secondPoint)
throw new IllegalArgumentException("Segment cannot be 0");
this.endPoint1 = new Point(firstPoint);
this.endPoint2 = new Point(secondPoint);
}