Skip to content

Instantly share code, notes, and snippets.

@amippy
amippy / file0.java
Last active April 17, 2016 14:29
筋トレ大好きな文系女学生のJava入門_カプセル化の目的&メリット ref: http://qiita.com/amippy/items/6d2f56881801d1521a8c
//アクセス制御されないプログラム
1 public class MuscleBoy{
2 int hp;
3 String name;
4 static int money;
5
6 void run(){
7 System.out.println(this.name + "は、逃げた!");
8 }
9 void drink(){
@amippy
amippy / file0.java
Created April 14, 2016 13:44
筋トレ大好きな文系女学生のJava入門_静的メンバ ref: http://qiita.com/amippy/items/cc150d4b64aaf53ee730
1 public class Main{
2 public static void main(String[] args){
3 MuscleBoy mb1 = new MuscleBoy();
4 mb1.hp = 100;
5 MuscleBoy mb2 = new MuscleBoy();
6 mb2.hp = 70;
7 }
8 }
@amippy
amippy / file0.java
Created April 9, 2016 16:00
筋トレ大好きな文系女学生のJava入門_コンストラクタ ref: http://qiita.com/amippy/items/ea83523e7ea72514518c
1 public class Main{
2 public static void main(String[] args){
3 MuscleBoy mb = new MuscleBoy(); //インスタンスを生成
4 mb.name = "ホエイ";           //初期値セット
5 mb.hp = 100; //初期値セット
6 MuscleGirl mg = new MuscleGirl(); //またインスタンスを生成
7 mg.name = "アミノ"; //また初期値
8 mg.hp = 100; //また初期値
9 Protein p = new Protein(); //インスタンスを生成
10 p.name = "プロテイン"; //初期値
@amippy
amippy / file0.java
Last active April 2, 2016 15:23
筋トレ大好きな文系女学生のJava入門〜クラス定義とオブジェクト生成①〜 ref: http://qiita.com/amippy/items/142165defc2d1fa3cbc8
1 public class Main {
2 public static void main(String[] args) {
3 Muscle m = new Muscle();
4 m.name = "腹筋";
5 System.out.println(m.name);
6 }
7 }
@amippy
amippy / file0.txt
Last active March 20, 2016 07:07
筋トレ大好きな文系女学生のJava入門〜メソッド〜 ref: http://qiita.com/amippy/items/acca2cda0a2b95a66c94
メソッドの定義
public static 戻り値の型 メソッド名(引数){
 メソッドが呼び出された時に実行される処理
}
@amippy
amippy / file0.java
Last active March 20, 2016 07:08
筋トレ大好きな文系女学生のJava入門〜配列〜 ref: http://qiita.com/amippy/items/7744f68673ff6eff60e7
1 public class MuscleWorld{
2 public static void main(String[] args){
3 int[] number = {10,20,30,40,50};
4 for(int i = 0; i < number.length; i++){
5 System.out.println(number[i]);
6 }
7 }
8}
@amippy
amippy / file0.txt
Last active March 20, 2016 07:08
筋トレ大好きな文系女学生のJava入門〜式と演算子〜 ref: http://qiita.com/amippy/items/28130139a60e66ebb7a7
【代表的な算術演算子】
+  足し算     2 + 8 =10
-  引き算     10 - 2 = 8
*  掛け算     2 x 5 = 10
/  割り算     3.2 / 2 →1.6 9/2 → 4
%  割り算のあまり 9 % 2 → 1
@amippy
amippy / file0.java
Last active February 28, 2016 15:14
文系大学生のJava入門 ref: http://qiita.com/amippy/items/96e8e725382881b6c9f3
1 public class HelloWorld{
2 public static void main(String[] args){
3 System.out.println("MuscleWorld!");
4 }
5}