I want to create all possible combinations of points (0,0),(0,1)...(12345,6789) and then all segments from these points.The code I have written is simple and with no optimization.  Is there any algorithm to generate it in less time?public static void main(String[] args) {    int m=12345;    int n=6789;    for(int x1=0;x1<=m;x1++)    {        for(int y1=0;y1<=n;y1++)        {            for(int x2=0;x2<=m;x2++)            {                for(int y2=0;y2<=n;y2++)                {                    for(int x3=0;x3<=m;x3++)                    {                        for(int y3=0;y3<=n;y3++)                        {                            for(int x4=0;x4<=m;x4++)                            {                                for(int y4=0;y4<=n;y4++)                                {                                           Point p1 = new Point(x1, y1);                                    Point p2 = new Point(x2, y2);                                    Point p3 = new Point(x3, y3);                                    Point p4 = new Point(x4, y4);                                    Segment s1 = new Segment(p1, p2);                                    Segment s2 = new Segment(p2, p3);                                    Segment s3 = new Segment(p3, p4);                                    Segment s4 = new Segment(p4, p1);                                    //operate on those segements                                }                            }                        }                    }                }            }        }    }}
Creating all possible combinations of points
java;performance;combinatorics