I'm new to this, my head aches from searching for the cause of the compiler errors. Help, anyone??
The file reads as follows: -------------- import java.io.*; import java.util.Scanner;
public class LesFraFil { public String filnavn = new String(); public String[] listeEngelsk; public String[] listeNorsk;
public int antallOrd(String filnavn) { Scanner scan = null; scan = new Scanner(new BufferedReader(new FileReader(filnavn))); if (scan.hasNext()) { antallOrd = scan.nextInt(); } // antall engelske ord i filen scan.close(); return; } // end antallOrd
public static void Les(int spraak, filnavn) throws IOException /* Error here ^ */ { int ii; Scanner scan = null; try { scan = new Scanner(new BufferedReader(new FileReader(filnavn))); String antallOrd = scan.nextInt(); listeEngelsk = new String[antallOrd]; // lese inn de engelske ordene listeNorsk = new String[antallOrd]; // og oversettelsene while (scan.hasNext()) { listeEngelsk[ii] = scan.nextString(); // lese inn engelsk ord listeNorsk[ii] = scan.nextString(); // lese inn norsk ord ii++; } // end while } finally { if (scan != null) { scan.close(); } } // end finally } // end try switch (int spraak) { /* ^ Error here */ case 1: return listeEngelsk; break; case 2: return listeNorsk; break; default: System.out.println("Feil ved lesing fra fil"); } // end switch } // end main
The main problem is that there are no comments on either the class or the two methods that describe their purpose. As a result, it is impossible to say what it is that they should be doing. Without knowing what the methods should do, it is not possible to give any meaningful comments on the compilation errors.