[Bluej-discuss] Ex 4.50

Davin McCall davmac at bluej.org
Wed Oct 4 15:12:01 BST 2006


The error messages produced by the compiler are a bit cryptic, but they are meaningful. In this case you will find the error message actually says something more like "size has private access in java.util.List". The reason is that your code accesses the (private) field member called "size" as if it were a field, when in fact what you need to do is call the (public) method member, "size()".

Using brackets "()" indicates that you are making a method call. Replace "notes.size" with "notes.size()" and this particular error should go away.

You may also need to change "int index;" into a proper initializer, eg "int index = 0;" before this code will compile.

Davin


On Wed, 4 Oct 2006 09:45:11 -0400 (EDT)
John Simonds <simonj2 at sage.edu> wrote:

> Thank you.  Any idea why the corrected version would then produce 'size has private access in the java util list?
> 
>  
>  
>  
> John Simonds
> Systems Technologist
> simonj2 at sage.edu
> (518)244-3111
> (518)292-1734
>  
>  
>  
> 
> 
> ---------------------------------------  
> Original E-mail  
> From: Brian Brookwell  
> Sent: 10/04/2006 09:12 AM  
> To: John Simonds , General discussion for users of BlueJ  
> Subject: Re: [Bluej-discuss] Ex 4.50  
> 
> 
> 
> 
> On 4-Oct-06, at 7:07 AM, John Simonds wrote:
> 
> 
> for(int index; index < notes.size; (index ++) }
> 
> 
> for (int index;index < notes.size; index++) {
> 
> 
> You had mismatched ( ) pairs and the brace was the wrong way around


More information about the bluej-discuss mailing list