-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
140 lines (117 loc) · 3.97 KB
/
Solution.java
File metadata and controls
140 lines (117 loc) · 3.97 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//Then Pilate went out again, and said to them, "Behold, I bring him out to you, that you may know that I find no basis for a charge against him." (John 19:4)
package com.javarush.task.task20.task2012;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
/*
OutputToConsole
*/
public class Solution {
public static String greeting = "Hello world";
/**
* OutputToConsole is the inner base class for improving your attentiveness.
* An OutputToConsole object encapsulates the information needed
* for the displaying [greeting] variable to the console.
* @author JavaRush
*/
public static class OutputToConsole implements Externalizable {
private int counter;
/**
* @param out A stream for an externalization
* @throws java.io.IOException
*/
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(counter);
}
/**
* @param in A stream for a de-externalization
* @throws java.io.IOException
* @throws ClassNotFoundException
*/
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
counter = in.readInt();
}
/**
* Class constructor specifying fake private field [i].
*/
public OutputToConsole(int counter) {
this.counter = counter;
}
/**
* Prints greeting message to console counter times.
*/
public void printMessage() {
for (int i = 0; i < counter; i++) {
System.out.println(greeting);
}
}
}
public static void main(String[] args) {
}
}
/*
OutputToConsole
Класс OutputToConsole должен сериализовываться с помощью интерфейса Externalizable.
Найди и исправь ошибку.
Требования:
1. Класс Solution.OutputToConsole должен поддерживать интерфейс Externalizable.
2. Класс OutputToConsole должен быть создан в классе Solution.
3. Класс OutputToConsole должен быть публичным.
4. Класс OutputToConsole должен быть статическим.
package com.javarush.task.task20.task2012;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
*
OutputToConsole
*
public class Solution {
public static String greeting = "Hello world";
/**
* OutputToConsole is the inner base class for improving your attentiveness.
* An OutputToConsole object encapsulates the information needed
* for the displaying [greeting] variable to the console.
* @author JavaRush
*/
public static class OutputToConsole implements Serializable {
private int counter;
/**
* @param out A stream for an externalization
* @throws java.io.IOException
*/
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(counter);
}
/**
* @param in A stream for a de-externalization
* @throws java.io.IOException
* @throws ClassNotFoundException
*/
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
counter = in.readInt();
}
/**
* Class constructor specifying fake private field [i].
*/
public OutputToConsole(int counter) {
this.counter = counter;
}
/**
* Prints greeting message to console counter times.
*/
public void printMessage() {
for (int i = 0; i < counter; i++) {
System.out.println(greeting);
}
}
}
public static void main(String[] args) {
}
}
*/