• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K&B Anonymous Inner Class.

 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot access sizzle directly. There might be a way of doing that using reflection, but that's not in SCJP objectives so you don't need to worry...
 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see - thanks ankit. however, can you show me that reflection code to access sizzle?? if its convenient for you?
 
Amrita Udupa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively you could include the sizzle in your popcorn class and then call it in the main method
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a small code that I created to call a method on an anonymous inner class object which is not a part of the super class of the anonymous inner class.


Remember I'm no reflection guru, I just looked at the docs and this article and made this program...
 
Leonardo Carreira
Ranch Hand
Posts: 489
Eclipse IDE Java Postgres Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.. what K&B stands for?..
sorry i don't know it abbreviation..

Thanks..
 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leonardo Carreira, the people around javaranch use k&B as short term of book Java 6 Study Guide by Katherine Sierra & Bert Bates.
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leonardo Carreira wrote:Hi.. what K&B stands for?..

It refers to SCJP Study Guide by Kathy Sierra and Bert Bates (K&B = Kathy & Bert)...
 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:
Remember I'm no reflection guru, I just looked at the docs and this article and made this program...


Mr.Ankit, it's absolutely fine if you are not guru, i just asked because i was not able to call method "sizzle()" through reflection my self.

Thanks
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Minhaj kaimkhani wrote:Mr.Ankit, it's absolutely fine if you are not guru,

Well I said that because I had to make the method local class' method (innerMethod) public otherwise I was getting an exception. But I'm sure that non-public members of a class can be accessed using reflection, I just don't know why it didn't work (and I'm not interested in knowing as of now as I don't have any reason why I should learn reflection inside out )...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic