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

