国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Good Java Style: Part 2

2019-11-18 14:43:09
字體:
來源:轉載
供稿:網友

  Good java Style: Part 2
By Thornton Rose

IntrodUCtion
This is the conclusion of a two-part series on Java coding style. In Good Java Style: Part 1

, I introduced my case for writing Java code using good habits, eXPlained why we should care about the way our code looks, and illustrated some general elements of good Java style. In this part, I illustrate more elements of good style and bring my case to a conclusion.

Source Files
There are many ways that a Java source file can be organized. Here is one that works well:


File header comment (optional).
Package declaration.
Blank line or other separator.
Import statements.
Blank line or other separator.
Class(es).

Example 1. Bad File Organization.


   package org.rotpad;
   import java.awt.*;
   import javax.swing.event.*;
   import org.javacogs.*;
   import javax.swing.*;
   import java.awt.event.*;
   class Foo {
    ...
   }
   public class RotPad extends JFrame {
    ...
   }


Example 2. Good File Organization.


   package org.rotpad;
   
   // Java classes
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import javax.swing.event.*;
   
   // JavaCogs classes
   import org.javacogs.*;
   
   /**
    * RotPad is a simple GUI application for performing rotation ciphers on plain
    * text.
    *
    * @author Thornton Rose
    * @version 1.0
    */
   public class RotPad extends JFrame {
      ...
   }
   
   //-----------------------------------------------------------------------------
   
   /**
    * Foo is ...
    *
    * @author Thornton Rose
    * @version 1.0


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沐川县| 卢湾区| 建德市| 精河县| 昭苏县| 民和| 长顺县| 攀枝花市| 阳东县| 昌吉市| 济宁市| 基隆市| 黄冈市| 塘沽区| 盘锦市| 新巴尔虎左旗| 偏关县| 宿松县| 肇州县| 白山市| 兰坪| 米脂县| 盐亭县| 沂源县| 广灵县| 济源市| 金山区| 吉水县| 拉萨市| 屯留县| 宁化县| 芒康县| 黎平县| 叶城县| 云林县| 获嘉县| 曲沃县| 龙南县| 板桥市| 宁化县| 胶南市|