Question: The code below will find intersection of 2 lines and return the point object. If point is only ever going to be created by IntersectionOf2Lines class, should i make point a nested class ? If not then why not ? Thanks

```
class Point {
    private final int x;
    private final int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    int getX() {
        return x;
    }

    int getY() {
        return y;
    }
}

public class IntersectionOf2Lines {

    public static Point calculateIntersection(Line line1, Line line2) {
        int x = (line2.getConstant() - line1.getConstant()) / (line1.getSlope() - line2.getSlope());
        int y = line1.getSlope() * x + line1.getConstant();

        return new Point(x, y);
    }

```

Answer: 
If the Point class is not needed by any other class and the Point class don't need access to the private class members of IntersectionOf2Lines, then you could make the Point class a *static nested class*.

A *static nested class* is a lighter inner class that has no access to the super class members and is often used like structs in C.

```
package main;

public class Main {

    public static void main(String[] args) {

        MyPoint p = new MyPoint();
        p.x = 5;
        System.out.println("x: "+ p.x);

    }

    private static class MyPoint {
        int x;
    }

}

```
Mathematically, Line is made of number of points. If you are creating Point class outside, you can use it to show point on particular line, end points of line, so it should be a normal class and not nested class to IntersectionOf2Lines.