Skip to content

Commit 2327db4

Browse files
committed
Line width <= 60
1 parent d24a985 commit 2327db4

22 files changed

Lines changed: 69 additions & 60 deletions

arrays/CompType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public int compareTo(CompType rv) {
2626
}
2727
private static Random r = new Random(47);
2828
public static Generator<CompType> generator() {
29-
return () -> new CompType(r.nextInt(100),r.nextInt(100));
29+
return () ->
30+
new CompType(r.nextInt(100),r.nextInt(100));
3031
}
3132
public static void main(String[] args) {
3233
CompType[] a =

arrays/PythonLists.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def getReversed(self):
1818
reversed.reverse() # Built-in list method
1919
return reversed
2020

21-
list2 = MyList(aList) # No 'new' needed for object creation
21+
# No 'new' necessary for object creation:
22+
list2 = MyList(aList)
2223
print(type(list2)) # <class '__main__.MyList'>
2324
print(list2.getReversed()) # [8, 7, 6, 5, 4, 3, 2, 1]
2425
#:~

concurrency/CloseResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CloseResource {
1212
public static void main(String[] args) throws Exception {
1313
ExecutorService exec = Executors.newCachedThreadPool();
1414
ServerSocket server = new ServerSocket(8080);
15-
try (InputStream socketInput =
15+
try(InputStream socketInput =
1616
new Socket("localhost", 8080).getInputStream()) {
1717
exec.execute(new IOBlocked(socketInput));
1818
exec.execute(new IOBlocked(System.in));

concurrency/GreenhouseScheduler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ public void run() {
139139
if(rand.nextInt(5) == 4)
140140
tempDirection = -tempDirection;
141141
// Store previous value:
142-
lastTemp += tempDirection * (1.0f + rand.nextFloat());
142+
lastTemp += tempDirection*(1.0f+rand.nextFloat());
143143
if(rand.nextInt(5) == 4)
144144
humidityDirection = -humidityDirection;
145-
lastHumidity += humidityDirection * rand.nextFloat();
145+
lastHumidity += humidityDirection*rand.nextFloat();
146146
// Calendar must be cloned, otherwise all
147147
// DataPoints hold references to the same lastTime.
148148
// For a basic object like Calendar, clone() is OK.

concurrency/NIOInterruption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void main(String[] args) throws Exception {
3434
InetSocketAddress isa =
3535
new InetSocketAddress("localhost", 8080);
3636
SocketChannel sc1 = SocketChannel.open(isa);
37-
try (SocketChannel sc2 = SocketChannel.open(isa)) {
37+
try(SocketChannel sc2 = SocketChannel.open(isa)) {
3838
Future<?> f = exec.submit(new NIOBlocked(sc1));
3939
exec.execute(new NIOBlocked(sc2));
4040
exec.shutdown();

containers/FillingLists.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//: containers/FillingLists.java
2-
// ©2015 MindView LLC: see Copyright.txt
2+
// 2015 MindView LLC: see Copyright.txt
33
// The Collections.fill() & Collections.nCopies() methods.
44
import java.util.*;
55

io/BasicFileOutput.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public static void main(String[] args)
99
BufferedReader in = new BufferedReader(
1010
new StringReader(
1111
BufferedInputFile.read("BasicFileOutput.java")));
12-
try (PrintWriter out = new PrintWriter(
13-
new BufferedWriter(new FileWriter(file)))) {
12+
try(PrintWriter out = new PrintWriter(
13+
new BufferedWriter(new FileWriter(file)))) {
1414
int lineCount = 1;
1515
String s;
1616
while((s = in.readLine()) != null )

io/Blip3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public static void main(String[] args)
4040
print("Constructing objects:");
4141
Blip3 b3 = new Blip3("A String ", 47);
4242
print(b3);
43-
try (ObjectOutputStream o = new ObjectOutputStream(
44-
new FileOutputStream("Blip3.out"))) {
43+
try(ObjectOutputStream o = new ObjectOutputStream(
44+
new FileOutputStream("Blip3.out"))) {
4545
print("Saving object:");
4646
o.writeObject(b3);
4747
}

io/Blips.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public static void main(String[] args)
4242
print("Constructing objects:");
4343
Blip1 b1 = new Blip1();
4444
Blip2 b2 = new Blip2();
45-
try (ObjectOutputStream o = new ObjectOutputStream(
46-
new FileOutputStream("Blips.out"))) {
45+
try(ObjectOutputStream o = new ObjectOutputStream(
46+
new FileOutputStream("Blips.out"))) {
4747
print("Saving objects:");
4848
o.writeObject(b1);
4949
o.writeObject(b2);

io/FileLocking.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
public class FileLocking {
88
public static void main(String[] args) throws Exception {
9-
try (FileOutputStream fos = new FileOutputStream("file.txt")) {
9+
try(FileOutputStream fos =
10+
new FileOutputStream("file.txt")) {
1011
FileLock fl = fos.getChannel().tryLock();
1112
if(fl != null) {
1213
System.out.println("Locked File");

0 commit comments

Comments
 (0)