i think its because of scope (Block) of res:
> while(i < p.length){
> String res = p[i].replace(p[i].charAt(1),' ');
> i++;
> }{{{scope of the res ends here}}}
> return res.trim();
please declare res outside while
On Thu, Jan 22, 2009 at 8:34 PM, teddybear <[email protected]> wrote:
>
> 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....
> }
> }
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---