• 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

Java code error

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

C:\payroll.java>javac PayrollPartTwo.java
PayrollPartTwo.java:149: error: class, interface, or enum expected
}
^
1 error


I cannot figure this out can somebody help I am new at this.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

How are you declaring your class? Are the braces "{}" (is this what they called) properly closed?
 
Vicky Bryan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

K. Tsang wrote:Welcome to the Ranch.

How are you declaring your class? Are the braces "{}" (is this what they called) properly closed?



Yes I have open and closing braces.

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It helps if you indent your code properly. You have extra braces.
 
Vicky Bryan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:It helps if you indent your code properly. You have extra braces.



Oh yes I know I have it all written out in Eclipse so thats all good just copied it from notepad sorry been a long few nights
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your problem is the file name does not match the class name. You use Employee (yet not public) but your file name is PayrollPartTwo? The compiler expects a class called PayrollPartTwo.
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

K. Tsang wrote:Your problem is the file name does not match the class name. You use Employee (yet not public) but your file name is PayrollPartTwo? The compiler expects a class called PayrollPartTwo.


No it doesn't. A non-public class can be in a file with any name and a .java file does not have to contain a class that matches its name.
The only rule for class and file names is that a public class has to be in a file with a matching name.
 
reply
    Bookmark Topic Watch Topic
  • New Topic