Not a statement compile error

Hi all,

I have the following piece of code and receive the "not a statement compile error", and don't know what the problem is. Can somebody let me know what am I doing wrong? There are other compile errors, but I need to take care of this first...

Any help is greatly appreciated.

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.BufferedWriter;

import java.util.*;

publicclass Ontology

{

publicstaticvoid main(String[] Args)

{

String path ="path";

String filename = Args[0];

Listfinal =new ArrayList();

String query = Args[1].toLowerCase();

try

{

BufferedReader in =new BufferedReader(new FileReader(path + filename));

String str;

while ((str = in.readLine()) !=null)

{

//System.out.println(str);

String patternStr ="|";

String[] fields = str.split(patternStr);

List elements =new ArrayList();

for (int a = 0; a < fields.lenght; a++)

{

elements.add(fields[a].toLowerCase());

}

final.add(elements);

}// while

in.close();

}// try

catch (Exception e)

{

e.printStackTrace();

}

for (int a = 0; a < final.size(); a++)

{

ArrayList al =final(a);

for (int b = 0; b < al.size(); b++)

{

if (!b.contains(query))

continue;

else

print(al);

}

}

publicstaticvoid print(ArrayList al)

{

// Prints the members of the ArrayList to stdout.

}

}// main()

}// class

Output:

Ontology.java:21: not a statement

Listfinal =new ArrayList();

^

Ontology.java:21:';' expected

Listfinal =new ArrayList();

^

Ontology.java:62: illegal start of type

final.add(elements);

^

Ontology.java:62: <identifier> expected

final.add(elements);

^

Ontology.java:79: illegal start of expression

for (int a = 0; a < final.size(); a++)

^

Ontology.java:81: illegal start of expression

ArrayList al =final(a);

^

Ontology.java:93: illegal start of expression

publicstaticvoid print(ArrayList al)

^

Ontology.java:97:';' expected

^

8 errors

[4519 byte] By [RonitTa] at [2007-11-27 6:11:19]
# 1
final is a Java keyword so it can not be used as a type name. Use a name like finalList instead. Do you know what final means? You should take a look before bothering with lists if you don't.
_helloWorld_a at 2007-7-12 17:17:33 > top of Java-index,Java Essentials,Java Programming...
# 2

Also this

public static void print(ArrayList al)

{

// Prints the members of the ArrayList to stdout.

}

} // main()

// <In here somewhere looks good

}//class

Should be declared outside of the main method.

Message was edited by:

_helloWorld_

_helloWorld_a at 2007-7-12 17:17:33 > top of Java-index,Java Essentials,Java Programming...