Skip to content

Commit ff09f50

Browse files
committed
refactor: simplify IO handling and make solve method static
1 parent f6a9c00 commit ff09f50

File tree

2 files changed

+12
-21
lines changed
  • src/main/java/com/lzw/solutions

2 files changed

+12
-21
lines changed

src/main/java/com/lzw/solutions/codeforces/p2190B1/Main.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,10 @@
66
import java.io.PrintWriter;
77

88
public class Main {
9+
private static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
10+
private static final PrintWriter out = new PrintWriter(System.out, true);
911

10-
private BufferedReader in;
11-
private PrintWriter out;
12-
13-
public Main() {
14-
in = new BufferedReader(new InputStreamReader(System.in));
15-
out = new PrintWriter(System.out);
16-
}
17-
18-
public static void main(String[] args) throws IOException {
19-
Main m = new Main();
20-
m.solve();
21-
m.close();
22-
}
23-
24-
private void close() {
25-
out.flush();
26-
out.close();
27-
}
28-
29-
private void solve() throws IOException {
12+
private static void solve() throws IOException {
3013
int t = Integer.parseInt(in.readLine());
3114
while (t-- > 0) {
3215
int n = Integer.parseInt(in.readLine());
@@ -35,4 +18,9 @@ private void solve() throws IOException {
3518
out.println(s);
3619
}
3720
}
21+
22+
public static void main(String[] args) throws IOException {
23+
solve();
24+
out.close();
25+
}
3826
}

src/main/java/com/lzw/solutions/sample/pjava_sample_buf/Main.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.lzw.solutions.sample.pjava_sample_buf;
22

3-
import java.io.*;
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.io.PrintWriter;
47

58
public class Main {
69
private static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

0 commit comments

Comments
 (0)