반응형

MAIN 

package com.company;

public class Main {

    public static void main(String[] args) {

        Thisis what = new Thisis();

        what.fingers = 2;
        what.foods = "banana";
        what.not = false;

        Thisis someone = new Thisis();

        someone.not = true;
        someone.foods = "melon";
        someone.fingers = 5;


        System.out.println(what.fingers);
    }
}

Class

package com.company;

public class Thisis {

    String foods = "cake";
    int fingers =  5;
    Boolean not = true;


    static void how(){
        System.out.println("deliciously");
    }

    static void when(){
        System.out.println("working");
    }

    static void who() {
        System.out.println("ToYourMom");
    }
}

클래스를 만들어서 메인에서 Thisis라는 클래스를 가져와서 다른 속성?(인스턴스)으로 사용 할 수 있다.

반응형

'개발언어 > JAVA' 카테고리의 다른 글

자바 간단한 어플 만들기.  (0) 2020.11.14
자바 VIEW  (0) 2020.11.11
자바 Iterator , hashmap, map  (0) 2020.11.04
자바 (get,set 사용법),쓰레드,Array  (0) 2020.11.02
JAVA  (0) 2020.03.14

+ Recent posts