Re: array problem
- From: "Ed" <EdVanords@xxxxxxx>
- Date: Mon, 12 Jun 2006 14:08:47 -0400
Thanks. Peter - I understood that in addition to declaring the array I had
to initialize each element also. In an earlier version of my code when I had
only the code you suggest the compiler objected, saying that the array "may
not be initialized" That is why I added the five lines referring to each
element.
"Peter Van Weert" <Peter.VanWeert@xxxxxxxxxxxxxx> wrote in message
news:1150132781.779254@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Can someone tell me what I'm doing wrong or point me to help towards a
solution. Thanks.
//Declare an array "doc"
DefaultStyledDocument[] doc;
//Instantiate and array "doc"
DefaultStyledDocument[] doc = new DefaultStyledDocument[5];
You have declared the variable doc twice. The following is correct:
//Declare and instantiate an array "doc"
DefaultStyledDocument[] doc = new DefaultStyledDocument[5];
or also correct:
//Declare an array "doc"
DefaultStyledDocument[] doc;
//Instantiate the array "doc"
doc = new DefaultStyledDocument[5];
I think (the error message of the compiler is a bit puzzling) this will
solve your problem.
Cheers,
Peter
.
- Follow-Ups:
- Re: array problem
- From: Oliver Wong
- Re: array problem
- References:
- array problem
- From: Ed
- Re: array problem
- From: Peter Van Weert
- array problem
- Prev by Date: Re: Yet another generics conundrum
- Next by Date: Re: Replace code
- Previous by thread: Re: array problem
- Next by thread: Re: array problem
- Index(es):
Relevant Pages
|