0

下面给出了一个名为 Abc 的类:

class Abc{

static int balance=1000;

public String method1(int amount, String password){
    String newPass=password;
    String str=newPass;
    balance=balance+amount;
    return str;
}
}

上面的类在下面的给定代码中使用:

class Xyz{

public static void main(String args[]){
    Abc abc=new Abc();
    int x=100;
    String y="gopal";
    String result=abc.method1(x,y);

    System.out.println("The password of the user is: "+result);
}
}

现在,问题是,我想获取密码值(即 y="gopal")传递的所有变量的名称。

有没有办法这样做?

简而言之,我只想跟踪用户输入的特定值并注意它在整个执行过程中通过的变量的名称。

4

1 回答 1

1

最好的方法是在 Eclipse 中以调试模式运行程序并观察变量的值。或者,您可以在控制台上打印变量的值并进行检查。我认为第一种方法更有效。

于 2013-03-21T19:39:55.820 回答