| Author |
array problem
|
Piyush Daiya
Ranch Hand
Joined: Jun 13, 2002
Posts: 67
|
|
hi, Im having array problem.Below is the code and have denoted where the error occurs.split function is deifned earlier, i havent shown it. Any pointers? Piyush --------------------------------------------- private String[] GetFullPath(String aPath) { String pathArr[] = split(aPath, "/"); String arrFullPath[]; if(pathArr.length > 0){ arrFullPath = pathArr; } else { arrFullPath [0] = "/"; ---> getting error here(variable not initialised) } return arrFullPath; } --------------------------------------
|
"A scientist is not person who gives right answers but a person who asks right questions"
|
 |
Irene Loos
Ranch Hand
Joined: Apr 15, 2002
Posts: 75
|
|
Hello Piyush, You are getting error because your initialization of array is actually occurs in the "if" block. <hr></blockquote> This statement may never be executed. You have to initialize ellements of the array before you can use them. Hope this will help. [ July 09, 2002: Message edited by: Irene Loos ]
|
Irene Loos
|
 |
Piyush Daiya
Ranch Hand
Joined: Jun 13, 2002
Posts: 67
|
|
Hi Irene, Can u suggest modifications to the code. If the 1st array length is zero then i wanna return "/", if not then whole array. Piyush
|
 |
Irene Loos
Ranch Hand
Joined: Apr 15, 2002
Posts: 75
|
|
There are many ways, try this: [ July 09, 2002: Message edited by: Irene Loos ]
|
 |
 |
|
|
subject: array problem
|
|
|