my dog learned polymorphism*
The moose likes Beginning Java and the fly likes 'class' or 'interface' expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " Watch " New topic
Author

'class' or 'interface' expected

Joel Allison
Greenhorn

Joined: Nov 17, 2009
Posts: 9
Getting this error

Prog8.java:57: 'class' or 'interface' expected
static int readData(String[] c, double[] p)


Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

See my comments at the end of this code block.



[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Joel Allison
Greenhorn

Joined: Nov 17, 2009
Posts: 9
Ahh I see yeah that makes sense. But when I remove that bracket, it says '}' is expected, more specifically it says:

~ $ javac Prog8.java
Prog8.java:167: '}' expected


I tried adding a bracket at the end of the code, but then it gave me a ton of other errors:

~ $ javac Prog8.java
Prog8.java:38: cannot find symbol
symbol : variable popultion
location: class Prog8
numCities = readData(cityName,popultion);
^
Prog8.java:41: cannot find symbol
symbol : variable popultion
location: class Prog8
printData(cityName,popultion,numCities);
^
Prog8.java:43: cannot find symbol
symbol : variable popultion
location: class Prog8
sortByName(cityName,popultion,numCities);
^
Prog8.java:45: cannot find symbol
symbol : variable popultion
location: class Prog8
printData(cityName,popultion,numCities);
^
Prog8.java:47: cannot find symbol
symbol : variable popultion
location: class Prog8
sortByPopulation(cityName,popultion,numCities);
^
Prog8.java:49: cannot find symbol
symbol : variable popultion
location: class Prog8
printData(cityName,popultion,numCities);
^
Prog8.java:51: cannot find symbol
symbol : variable name
location: class Prog8
printPopulation(name,cityName,popultion,numCities);
^
Prog8.java:51: cannot find symbol
symbol : variable popultion
location: class Prog8
printPopulation(name,cityName,popultion,numCities);
^
Prog8.java:106: swap(java.lang.String[],int,int) in Prog8 cannot be applied to (double[],int,int)
swap(p, m, last);
^
Prog8.java:125: swap(java.lang.String[],int,int) in Prog8 cannot be applied to (double[],int,int)
swap(p, m, last);
^
Prog8.java:163: cannot find symbol
symbol : variable a
location: class Prog8
tmp = (a[i]);
^
Prog8.java:163: cannot find symbol
symbol : variable i
location: class Prog8
tmp = (a[i]);
^
Prog8.java:164: cannot find symbol
symbol : variable a
location: class Prog8
a[i] = (a[j]);
^
Prog8.java:164: cannot find symbol
symbol : variable i
location: class Prog8
a[i] = (a[j]);
^
Prog8.java:164: cannot find symbol
symbol : variable a
location: class Prog8
a[i] = (a[j]);
^
Prog8.java:164: cannot find symbol
symbol : variable j
location: class Prog8
a[i] = (a[j]);
^
Prog8.java:165: cannot find symbol
symbol : variable a
location: class Prog8
a[j] = (tmp);
^
Prog8.java:165: cannot find symbol
symbol : variable j
location: class Prog8
a[j] = (tmp);


So is there just something small I'm missing? I feel like the code is just about right but I'm not sure.
Joel Allison
Greenhorn

Joined: Nov 17, 2009
Posts: 9
Well I rewrote some stuff, but I still can't seem to find my problem. Here is the error I get, followed by the current complete code I have. Hopefully you pinpoint it, thanks in advance for any help and thanks for the help so far!

~ $ javac Prog8.java
Prog8.java:164: '}' expected



Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

That } you removed should still close the class, but after all the methods, not just after the first one like you initially had.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: 'class' or 'interface' expected
 
Similar Threads
StringBuffer class
LinearProgramming in Java
Fybunic series
Help with sort function
applet and servlet communication error: java.io.EOFException