| Author |
Why do I get an initialization error here?
|
Maduranga Liyanage
Ranch Hand
Joined: May 25, 2005
Posts: 124
|
|
Hello; I have declared an inner class as following: When I compile the class I get the following error: But when I declare selectedFileNames as just a String (not String[] and no [counter]), it works fine. What am I doing wrong here. Cheers. [ July 28, 2008: Message edited by: Maduranga Liyanage ] [ July 28, 2008: Message edited by: Maduranga Liyanage ]
|
 |
Manuel Leiria
Ranch Hand
Joined: Jul 13, 2007
Posts: 171
|
|
You must initialize the array String[] selectedFileNames before using it.Something like this: String[] selectedFileNames = new String[selectedFiles.length]; but you must know a priori the size [ July 28, 2008: Message edited by: Manuel Leiria ]
|
Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
|
 |
Maduranga Liyanage
Ranch Hand
Joined: May 25, 2005
Posts: 124
|
|
Arrr... Thanks a lot mate. I guess I have to use an ArrayList... I cannot know the length in advance. Thanks again.
|
 |
Manuel Leiria
Ranch Hand
Joined: Jul 13, 2007
Posts: 171
|
|
Originally posted by Maduranga Liyanage: Arrr... Thanks a lot mate. I guess I have to use an ArrayList... I cannot know the length in advance. Thanks again.
From your code I see that selectedFileNames array will have the same length as the selectedFiles array.
|
 |
 |
|
|
subject: Why do I get an initialization error here?
|
|
|