The problem in your case is that you want to return three values from sortFile(), However you cannot return more than one value from a method that returns an int.
One way to solve this problem is to instead of returning an int from sortFile(), return an int array with those three values,
public static void main(String[] args) {
int [] myArray = sortFile(args[0]); // this returns an int array with 3 variables, nWords, nSyllables, nSentences
getFRE(myArray);
}
You also need to change getFre() so that it accepts an array as a parameter.
However, as some other people has mentioned, wrapping your values in a class is another option:
public class Words {
// declare variables;
private int nWords, nSyllables, nSentences;
// getters and setters
public void setnWords(int nWords) {
this.nWords = nWords;
}
public void setnSyllables(int nSyllables) {
this.nSyllables = nSyllables;
}
public void setnSentences(int nSentences) {
this.nSentences = nSentences;
}
public int getnWords() {
return nWords;
}
public int getnSyllables() {
return nSyllables;
}
public int getnSentences() {
return nSentences;
}
}
Make sortFile() return an instance of Words and make your getFre() accept an instance of Words as a parameter. Your main class would look like :
public static void main(String[] args) {
Words myWords = sortFile(args[0]); // this returns an instance of the Words class
getFRE(myWords);
}