java class 불러오기

limchard·2023년 10월 25일
0

java

목록 보기
9/48
import org.opentutorials.iot.Elevator; // import : 불러오다.
import org.opentutorials.iot.Security;
import org.opentutorials.iot.Lighting;

public class OkJavaGoInHome {

public static void main(String[] args) {

String id = "JAVA APT 402"; // 왼쪽에 더블클릭하여 생긴 점을 break pointer라고 한다.

// Elevator call
Elevator myElevator = new Elevator(id);
myElevator.callForUp(1);

// Security off
Security mySecurity = new Security(id);
mySecurity.off();

// Light on
Lighting HallLamp = new Lighting(id+" / Hall Lamp");
HallLamp.on();

Lighting floorLamp = new Lighting(id+" / Hall Lamp");
floorLamp.on();
	}
}

다른 사람들이 만들어 놓은 class를 불러올 시에 활용하는 방법이다.
다른사람의 class는 폴더 째로 드래그 앤 드롭으로 Navigator에 만들어놓은 내 프로젝트 안에 넣으면 된다.
코드에 class를 넣어야 할 시에 원래는 'org.opentutoricals.iot.Elevator'를 적어야 한다.
즉, class위치를 일일이 적어줘야 한다.
class위치가 길고 일일이 기입하기 힘들기 때문에 불러오다의 의미인 import를 위 그림과 같이 먼저 적어 놓으면 class위치를 그때그때 적지 않고 마지막 최종 class파일 이름만 적으면 바로 적용 된다.

profile
java를 잡아...... 하... 이게 맞나...

0개의 댓글