The Artima Developer Community
Sponsored Link

Java Answers Forum
error: <identifier> expected and illegal start of type

1 reply on 1 page. Most recent reply: Feb 12, 2008 5:23 AM by Vincent O'Sullivan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Mary F

Posts: 1
Nickname: maryme
Registered: Feb, 2008

error: <identifier> expected and illegal start of type Posted: Feb 11, 2008 9:41 AM
Reply to this message Reply
Advertisement
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

}
------------


Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: error: <identifier> expected and illegal start of type Posted: Feb 12, 2008 5:23 AM
Reply to this message Reply
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.

Flat View: This topic has 1 reply on 1 page
Topic: error: <identifier> expected and illegal start of type Previous Topic   Next Topic Topic: If class Y extends class X, the two classes are in different packages...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use