⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staticnames.java

📁 程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件
💻 JAVA
字号:
package examples.classes;

/** A Java class to demonstrate how static members
  * are defined, initialized, and used.
  */
public class StaticNames {

   private static String[] names;

   /** Method to write the list of names to a 
     * specified <code>PrintStream</code> object
     * @param s The printstream to which the names
     *          are written
     */
   public static void printNames(
                         java.io.PrintStream s ) {
      for ( int i=0; i<names.length; i++ ) {
         s.println( names[i] );
      }
   }

   /** The test method for the class
     * @param args Not used
     */
   public static void main( String[] args ) {
      printNames( System.out );
   }

   /** Static initializer */
   static {
      names = new String[4];
      names[0] = "Billy";
      names[1] = "Alyssa";
      names[2] = "Amanda";
      names[3] = "Henry";
   }
}

⌨️ 快捷键说明

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