import java.io.File; Can someone fix the errors that I'm getting in this java code . Thank you.
import java.io.FileNotFoundException; import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; public class Project1 { private static class Marriage { private int n; private Person[] men; private Person[] women; private Marriage(int n) { this.n = n; this.men = new Person[n]; this.women = new Person[n]; for (int i = 0; i < n; ++i) { this.men[i] = new Person(true); this.women[i] = new Person(false); } } private void addRank(Person p, Person r, int n) { p.addRank(r, n); } private void getEngagements() { ArrayList freeMen = new ArrayList(); for (int i = 0; i < this.n; ++i) { freeMen.add(this.men[i]); } while (freeMen.size() > 0) { Person man = freeMen.remove(0); Person woman = man.getNextPossiblePartner(); Person currEngagement = woman.getEngagement(); if (currEngagement == null) { man.setEngagement(woman); woman.setEngagement(man); } else { if (currEngagement.is BetterThan(man, woman)) { freeMen.add(currEngagement); currEngagement.setEngagement(null); man.setEngagement(woman); woman.setEngagement(man); } else { freeMen.add(man); } } } } private void getEngagementsWomen() { ArrayList freeWomen = new ArrayList(); for (int i = 0; i < this.n; ++i) { freeWomen.add(this.women[i]); } while (freeWomen.size() > 0) { Person woman = freeWomen.remove(0); Person man = woman.getNextPossiblePartner(); Person currEngagement = man.getEngagement(); if (currEngagement == null) { man.setEngagement(woman); woman.setEngagement(man); } else { if (currEngagement.isBetterThan(man, woman)) { freeWomen.add(currEngagement); currEngagement.setEngagement(null); man.setEngagement(woman); woman.setEngagement(man); } else { freeWomen.add(woman); } } } } private String toString() { StringBuilder out = new StringBuilder(); for (int i = 0; i < n; ++i) { out.append(this.men[i].toString() + " "); } for (int i = 0; i < n; ++i) { out.append(this.women[i].toString() + " "); } return out.toString(); } public void printEngagements() { System.out.println("Output when men propose: "); System.out.println(this.toString() + " "); System.out.println("Output when women propose: "); this.getEngagementsWomen(); System.out.println(this.toString()); } public static class Person { private boolean isMan; private ArrayList ranks; private Person engagement; private int currRank; public Person(boolean isMan) { this.isMan = isMan; this.ranks = new ArrayList(); this.engagement = null; this.currRank = 0; } public void addRank(Person p, int n) { if (this.isMan) { this.ranks.add(p); } else { this.ranks.add(n - 1, p); } } public Person getEngagement() { return this.engagement; } public void setEngagement(Person p) { this.engagement = p; } public Person getNextPossiblePartner() { return this.ranks.get(this.currRank); } public void moveUp() { ++this.currRank; } public boolean isBetterThan(Person p1, Person p2) { if (this.isMan) { return this.ranks.indexOf(p1) < this.ranks.indexOf(p2); } else { return this.ranks.indexOf(p2) < this.ranks.indexOf(p1); } } public String toString() { StringBuilder out = new StringBuilder(); out.append("{"); for (int i = 0; i < this.ranks.size(); ++i) { out.append("(" + (this.isMan ? "m" : "w") + (i + 1) + ", " + (this.isMan ? "w" : "m") + (this.ranks.indexOf(this.engagement) + 1) + ")"); if (i != this.ranks.size() - 1) { out.append(", "); } } out.append("}"); return out.toString(); } } } public static void main(String[] args) throws FileNotFoundException { File file = new File(args[0]); Scanner sc = new Scanner(file); int n = Integer.parseInt(sc.nextLine()); Marriage marriage = new Marriage(n); for (int i = 0; i < n; ++i) { String[] ranks = sc.nextLine().split(" "); for (int j = 0; j < n; ++j) { marriage.addRank(marriage.men[i], marriage.women[Integer.parseInt(ranks[j]) - 1], n); } } for (int i = 0; i < n; ++i) { String[] ranks = sc.nextLine().split(" "); for (int j = 0; j < n; ++j) { marriage.addRank(marriage.women[i], marriage.men[Integer.parseInt(ranks[j]) - 1], n); } } marriage.getEngagements(); marriage.printEngagements(); } }