전체 글 (127) 썸네일형 리스트형 [Java] Interface package org.opentutorials.javatutorials.interfaces.example1; interface I{ public void z(); } class A implements I{ public void z(){} } 클래스 A 뒤의 implements I는 이 클래스가 인터페이스 I를 구현하고 있다는 의미 그것은 3행의 interface I의 맴버인 public void z() 메소드를 클래스 A가 반드시 포함하고 있어야 한다는 뜻 [Java] final final 변수 package org.opentutorials.javatutorials.fanalTest; class Calculator { static final double PI = 3.14; int left, right; public void setOperands(int left, int right) { this.left = left; this.right = right; Calculator.PI = 6; //error } public void sum() { System.out.println(this.left + this.right); } public void avg() { System.out.println((this.left + this.right)/2); } } public class Calcul.. [Java] abstract package org.opentutorials.javatutorials.abstractclass; abstract class A { } public class AbstractTest { public static void main(String[] args) { A obj = new A(); } } Exception in thread "main" java.lang.Error: Unresolved compilation problem: Cannot instantiate the type A 에러가 뜬다 메소드 중에 1개라도 abstract 메소드가 있으면 클래스도 abstract 클래스가 되어야 한다. package org.opentutorials.javatutorials.abstractclass; abstrac.. 이전 1 ··· 26 27 28 29 30 31 32 ··· 43 다음