You've declared your inside the while loop, so once the loop is completed the variable is out of scope and not available to the rest of the method.
Move the declaration outside the while loop and you'll be in business (at least in terms of allowing res to be returned).
Brenden
| teddybear <[email protected]>
Sent by: [email protected] 23/01/2009 03:05 PM
|
|
Hi..... I seem to have a problem with my static method... The compiler
says that it cannot resolve variable "res" I dunno what to do pls
help.... thnx
here's my code for the static...
public class MyOwnBuiltinClassesProject {
public static String generateNewName(String[] p){
int i = 0;
while(i < p.length){
String res = p[i].replace(p[i].charAt(1),' ');
i++;
}
return res.trim();
}
public static void main(String[] args){
// I didn't start my main yet....
}
}
This email is sent by Australian Insurance Holdings Pty Ltd or a related body corporate (AIH) and is for the intended addressee. The views expressed in this email and attachments (email) reflect the views of the stated author but may not reflect views of AIH. This email is confidential and subject to copyright. It may be privileged. If you are not the intended addressee, confidentiality and privilege have not been waived and any use, interference with, or disclosure of this email is unauthorised. If you are not the intended addressee please immediately notify the sender and then delete the email. AIH does not warrant that this email is error or virus free.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---
