scope.txt

来自「java的一经典教程」· 文本 代码 · 共 35 行

TXT
35
字号
// Experiment with variable scope

import javax.swing.JOptionPane;

public class Scope
{
     public static int b = 25;
     // This is a class variable. It is not declared
     // in the body of any methods. What do you think its
     // scope will be?

     public static void doStuff()
     {
          int a = 3;

          if (a > b)
                JOptionPane.showMessageDialog(null,
                   a + " is larger than "  + b);
          else
               JOptionPane.showMessageDialog(null,
                  a + " is smaller than "  + b);
     }


     public static void main(String[] args)
     {
          int a = 15;
          int b = 2;

          doStuff();

          System.exit(0);
     }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?