Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > anonymous class questions - why final?

Reply
Thread Tools

anonymous class questions - why final?

 
 
puzzlecracker
Guest
Posts: n/a
 
      07-29-2008
In this example:

static List<Integer> intArrayAsList(final int[] a)
{
if(a==null)
throw new NullPointerException();

return new AbstractList<Integer>(){
public Integer get(int i){
return a[i];
}
//and other methods like set and size
};

}

I thought that idea of final in the context of anonymous class that
argument passed to it will not be modified outside of it's scope.
However, here this array a can modified elsewhere, say in the
function that called intArrayAsList, defeating the purpose of final to
begin with.

Please elaborate, why does it have to really be final?

Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
anonymous class questions - why final? sasha Java 3 07-29-2008 02:46 AM
anonymous class questions - why final? puzzlecracker Java 0 07-29-2008 01:52 AM
Is this a local anonymous class or a member anonymous class Reporter Java 3 05-12-2007 05:23 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM



Advertisments