• Post Reply Bookmark Topic Watch Topic
  • New Topic

use of final modifyer  RSS feed

 
lupercal james
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HiI have two questions

Can you tell me why the author uses final in this method




Thanks

What does notifyHitModelListener do?





The complete code is listed here

http://www.onjava.com/onjava/2004/07/07/examples/mvc-traditional.zip

The description text here

http://www.onjava.com/pub/a/onjava/2004/07/07/genericmvc.html
 
Kevin Smither
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He uses final so that the reference cannot be inadvertantly changed such as:

addHitModelListener (final HitModelListener hitModelListener) {
hitModelListener = new HitModelListener(); //NO!!
}
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does notifyHitModelListener do?




Answer to Q2:
together these two methods loop through a collection of listeners and call hitModelChanged() on each of them
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!