수업소개
인터페이스의 기본적인 형식을 소개해드립니다.
강의
소스코드
https://github.com/egoing/java-interface/commit/45364a2f7c70ca6976b6abb1b1ca1b120f5ddc6c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | interface Calculable{ double PI = 3.14 ; int sum( int v1, int v2); } interface Printable{ void print(); } class RealCal implements Calculable, Printable{ public int sum( int v1, int v2) { return v1+v2; } public void print() { System.out.println( "This is RealCal!!" ); } } public class InterfaceApp { public static void main(String[] args) { RealCal c = new RealCal(); System.out.println(c.sum( 2 , 1 )); c.print(); System.out.println(c.PI); } } |