인터페이스는 실제 기능이 없고 추상메소드와 상수만 존재한다.
private 접근제한자를 사용할 수 없다.
객체 타입으로만 사용가능하다.
private 접근제한자를 사용할 수 없다.
객체 타입으로만 사용가능하다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
public interface Interface1{
public static int CONSTANT_INT =10;
public void calculate();
}
public interface Interface2{
public static int CONSTANT_STRING =10;
public String getStr();
}
public class InterfaceClass implements Interface1, Interface2{
@Override
public void calculate(){...}
@Override
public String getStr(){...}
}
public class MainClass{
public static void main(String args[]){
// tpye = InterfaceClass
InterfaceClass interfaceClass = new InterfaceClass();
interfaceClass.calculate();
interfaceClass.getStr();
// tpye = Interface1
Interface1 inter1 = new InterfaceClass();
inter1.calculate();
// tpye = Interface2
Interface2 inter2 = new InterfaceClass();
inter2.getStr();
}
}
| cs |
댓글
댓글 쓰기