Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'class' or 'interface' expected

 
Joel Allison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting this error

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


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See my comments at the end of this code block.

 
Joel Allison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That } you removed should still close the class, but after all the methods, not just after the first one like you initially had.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic