4,
lwa
POLITECHNIKA RZESZOWSKA • WydzW Beatrctecnn*: Inftenatye
// definicja interfejsu
public interface
Mylnterfaoe { void myMethodl(); void myMethod2();
Tl
c HainClass.jawa
C:\>jaua HainClass kathodl Nsthod2
1
public class MainClass (
public static void main(Strir.g[] args) mm+ My Inter face obj 1 = new MyClass () ; mm+ MyClass cbj2 = new MyClass i) ; ob j 1. myMethodl () ; objl.myMethod2();
// objl.myMethod3(); Błąd !!f obJ2.myMethod3();
)
)
class MyClass implements Mylnterfaoe {
public void myMethodl() (
System.out.println("myMethodl");
J
public void myMethod2() {
System.out.println("rayMethod2");
)
^ public void myMethod3() {
System.out.println("myMethodl");