java中的作用域变量

java中的作用域变量,java,Java,我有密码, 我们需要在我评论的地方找到范围变量。 但我怀疑args是否属于范围变量 以下是代码: public class HelloWorld { public static int foo(int num) { int other_num = 2; // num , other_num return num % other_num; } public static void main(String[] args) {

我有密码, 我们需要在我评论的地方找到范围变量。 但我怀疑
args
是否属于范围变量

以下是代码:

public class HelloWorld {
   public static int foo(int num) {
       int other_num = 2;
       // num , other_num
       return num % other_num;
   }

   public static void main(String[] args) {
       int odd = 0;

       int x = 13;
       for (int value = 0; value < x; value++) {
           // value , odd , x 
           boolean local_odd = false;
           int r = foo(value);
           if (r == 1) {
               // value , odd , x , local_odd, r
               local_odd = true;
           } else {
               int div = value/2;
               System.out.println(div +" divides "+ value);
               // value , odd , x , local_odd, r , div
           }
           if (local_odd) {
               odd++;
           }
       }
       System.out.println(odd+" odd numbers smaller than "+x);
       // odd , x
   }
}
公共类HelloWorld{
公共静态intfoo(intnum){
int other_num=2;
//num,其他_num
返回数值%other_num;
}
公共静态void main(字符串[]args){
int奇数=0;
int x=13;
对于(int值=0;值
参数的范围在main()中。你可以退房
args
是一个方法参数,因此只有在main()中才有效,如果这是您所要求的

你的问题不清楚也不恰当。请详细说明,但“在盗版点写下范围变量”是不可理解的。“海盗”的意思是“与海盗有关”,这可能不是你想要的。一个“范围变量”应该表示什么?在我看来,这是毫无意义的。每个变量都有其可见和有效的作用域。