Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Annoymouse class always require ;(semi colon)  RSS feed

 
Ranch Hand
Posts: 104
Java Netbeans IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is code first

and second
so whyn't there is semicolon in first code it is also a annoymouse class??
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have combined two statement in one statement in first code.There is just one statement and so one ;
 
appu sharma
Ranch Hand
Posts: 104
Java Netbeans IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Brij Garg wrote:You have combined two statement in one statement in first code.There is just one statement and so one ;


but what is the syntax of annoymouse class??? it inlude semi colon....
 
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have to combine two operation - creation of object and calling the method then it will be treated as a single entity like



Here you do not have to place a semicolon between test() and doSomething() method.

The same way while declaring an anonymous class you can combine the two operation in one unit and you have to write a single semicolon at the end of the statement.

Remember - Semicolon represents "End Of The Statement"
 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here you have to give two semicolons as the object creation is one statement and calling the method is another statement.
But for,

you need only one semicolon as you have done the two in the same statement.
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!