-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticm.java
More file actions
44 lines (32 loc) · 780 Bytes
/
Copy pathStaticm.java
File metadata and controls
44 lines (32 loc) · 780 Bytes
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
38
39
40
41
42
43
44
package interfaces;
/**
* Created by WERT on 18.01.2017.
*/
//статические методы
interface MyInt {
static void prt1() {
System.out.println("PRT1 in MyInt");
}
void prt2();
}
class Prt implements MyInt {
@Override
public void prt2() {
System.out.println("PRT2 in Prt");
}
}
public class Staticm implements MyInt {
public static void main(String[] args) {
// вызов статического метода на интерфейсе
MyInt.prt1();
Prt prt = new Prt();
prt.prt2();
// prt.prt1(); // ошибка
Staticm ifs = new Staticm();
ifs.prt2();
}
@Override
public void prt2() {
System.out.println("PRT2 in main()");
}
}