This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java error class, interface, or enum expected

 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • 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?



 
Harsha Ka
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrong forum..

But nevertheless you have put your main method outside the class
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
ya changed the format. thank's yaar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic