-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
92 lines (72 loc) · 2.21 KB
/
Copy pathMain.java
File metadata and controls
92 lines (72 loc) · 2.21 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Main.java
public class Main {
public static void main(String[] args) {
MyInterface myInterface = new MyInterfaceImpl();
myInterface.sayHello();
MyInterfaceImpl multiImpl = new MyInterfaceImpl();
multiImpl.sayHello();
multiImpl.sayGoodbye();
FileLoader fileLoader = new FileLoader();
fileLoader.load("myfile.txt");
fileLoader.load(java.nio.file.Paths.get("mypath"));
MyInterface.print("Static method call!");
Storable storable = new Car();
storable.store();
Serializable serializable = new Car();
// serialize metodları burada sadece çağrılıyor,
// gerçek dosya yazımı için Writer gereklidir.
serializable.serializeToXML(null);
serializable.serializeToJSON(null);
}
}
interface MyInterface {
String hello = "Hello";
void sayHello();
static void print(String text) {
System.out.println(text);
}
}
class MyInterfaceImpl implements MyInterface, MyOtherInterface {
public void sayHello() {
System.out.println(MyInterface.hello);
}
public void sayGoodbye() {
System.out.println("Goodbye");
}
}
interface MyOtherInterface {
void sayGoodbye();
}
interface ResourceLoader {
Resource load(String resourcePath);
default Resource load(java.nio.file.Path resourcePath) {
System.out.println("Default load from Path");
return null;
}
}
class FileLoader implements ResourceLoader {
public Resource load(String resourcePath) {
System.out.println("Loading from String path: " + resourcePath);
return null;
}
}
interface Storable {
void store();
}
interface Serializable {
void serializeToXML(java.io.Writer writer);
void serializeToJSON(java.io.Writer writer);
}
class Car implements Storable, Serializable {
public void store() {
System.out.println("Storing car...");
}
public void serializeToXML(java.io.Writer writer) {
System.out.println("Serializing car to XML...");
}
public void serializeToJSON(java.io.Writer writer) {
System.out.println("Serializing car to JSON...");
}
}
// Resource sınıfı basit tanım olarak:
class Resource {}