9 Replies Latest reply: Jul 18, 2008 7:55 AM by 843785 RSS

    String becomes null

    843785
      I am having a problem where a string is being passed between several methods and then finally to a method in another class, I have tested the string at several points in my program and the string's value is becoming null at the point that it is passed into the method in the other class, here is a simplified example of what I have:
           public class one
           {
                public void methodOne()
                {
                     String x = "something";
                     methodTwo(x);
                }
                
                public void methodTwo(String x)
                {
                     ClassTwo ct = new ClassTwo(); 
                     //I tested 'x' here and it still had the correct value
                     ct.methodThree(x);
                }
           }
           
           public class two
           {
                public void methodThree(String x)
                {
                     //When tested here x had a value of null
                }
           }
      Can anyone explain why this is happening? Thanks.