• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

'class' or 'interface' expected

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Getting this error

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


 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic