• 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 error class, interface, or enum expected

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i am having an code like this for split program in java



[Added code tags - see UseCodeTags for details]


and i am getting an error like this

StringSplit.java:21: class, interface, or enum expected
public static void main(String args[]) throws Exception{
^
StringSplit.java:23: class, interface, or enum expected
ss.doit();
^
StringSplit.java:24: class, interface, or enum expected
}
^
3 errors

can any one help me how to get out the result?



 
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wrong forum..

But nevertheless you have put your main method outside the class
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(I've moved the forum).

It's more obvious once the code is formatted correctly (I've just added code tags and fixed the indentation - see UseCodeTags if you want to know more about them). Then you can clearly see the main method is outside the class, as Harsha says. In Java all code must be inside a class.
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya changed the format. thank's yaar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic