Skip to content

Instantly share code, notes, and snippets.

@kdmgs110
Created December 2, 2016 02:40
Show Gist options
  • Save kdmgs110/59c658773b90a6f52ef2bd6104f5b355 to your computer and use it in GitHub Desktop.
Save kdmgs110/59c658773b90a6f52ef2bd6104f5b355 to your computer and use it in GitHub Desktop.
オブジェクト指向①
package pass01;
import lib.Input;
public class Pass01_01 {
/*
* オブジェクト指向(P288)
* 部品化、規格化
* 汎用システムができる
* オブジェクト=対象
* Object has many data
* Object has many method
* クラス=設計図
* クラス has many インスタンス=オブジェクト
* ローカル変数:メソッド内で終わる
* フィールド変数:クラス内で使える
* staticのないメソッド=インスタンスメソッド
*/
public static void main(String[] args) {
int number = 0; //ローカル変数
int sum = 0;//ローカル変数
while((number=Input.getInt())!= 0){
sum += number;
}
System.out.println("合計は"+sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment