Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code explanation

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone please expalin the code below,what this code says

class h {

Fa fa = new Fa() {

public Object make() {
return new js();
}
};

}
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't look like it compiles.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you get that from? It is full of all sorts of stylistic unconventialities. If you are copying from books or website, please Quote Your Sources.

You need to have a class js with a no-arguments constructor, and a class Fa, then it is actually very similar to this thread. It is an anonymous subclass of Fa with a make() method.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you say "stylistic unconventialities" again I may need to pay someone to smack you
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I choose who it is? As long as it isn't Rob.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
Oh, no. That means you will do it!

Shall we get back to the official subject of this thread?
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all

I do not want to know whether it will complie or not.It is part of successful code,I just want explanation,you all think that it is a pseudo code.
[ October 13, 2008: Message edited by: jacob deiter ]
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer has been given.

It is creating in instance of a subclass of Fa that is anonymous (it has no name). The subclass contains one method that has been customized.


Standard:


Anonymous Subclass:


you normally don't see this in hand-coded Java,
but you often see it in machine-generated Java code,
[ October 13, 2008: Message edited by: Bill Shirley ]
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Bill
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
Can I choose who it is? As long as it isn't Rob.

If the question was about who was going to kick you, you'd beg for me to do it. I still have just a little power in my kicking leg

Originally posted by Bill Shirley:
you normally don't see this in hand-coded Java,

Then you haven't seen my code. Especially in user interface programming I do it all the time:

And yes, I code 90% of my code by hand. The only code I let Eclipse generate for me is getters and setters, and even those I tweak to get at least the Javadocs correct. "Sets the myField"... ARGH!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic