Skip to content

Commit 5022896

Browse files
committed
Changed as many duplicate file names as possible
1 parent 90563b9 commit 5022896

10 files changed

Lines changed: 43 additions & 44 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// concurrent/Prime.java
1+
// concurrent/ParallelPrime.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
@@ -9,7 +9,7 @@
99
import java.nio.file.*;
1010
import java.nio.charset.*;
1111

12-
public class Prime {
12+
public class ParallelPrime {
1313
static final int COUNT = 100_000;
1414
public static boolean isPrime(long n) {
1515
return rangeClosed(2, (long)Math.sqrt(n))
@@ -21,7 +21,7 @@ public static void main(String[] args)
2121
List<String> primes =
2222
iterate(2, i -> i + 1)
2323
.parallel() // [1]
24-
.filter(Prime::isPrime)
24+
.filter(ParallelPrime::isPrime)
2525
.limit(COUNT)
2626
.mapToObj(Long::toString)
2727
.collect(Collectors.toList());

concurrent/Summing.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ static void timeTest(String id, long checkValue,
2323
public static final int SZ = 100_000_000;
2424
// This even works:
2525
// public static final int SZ = 1_000_000_000;
26-
// Gauss's formula:
2726
public static final long CHECK =
28-
(long)SZ * ((long)SZ + 1)/2;
27+
(long)SZ * ((long)SZ + 1)/2; // Gauss's formula
2928
public static void main(String[] args) {
3029
System.out.println(CHECK);
3130
timeTest("Sum Stream", CHECK, () ->
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
// enums/Burrito.java
1+
// enums/Burrito2.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
5-
// {java enums.Burrito}
5+
// {java enums.Burrito2}
66
package enums;
7-
import static enums.Spiciness.*;
7+
import static enums.SpicinessEnum.*;
88

9-
public class Burrito {
10-
Spiciness degree;
11-
public Burrito(Spiciness degree) {
9+
public class Burrito2 {
10+
SpicinessEnum degree;
11+
public Burrito2(SpicinessEnum degree) {
1212
this.degree = degree;
1313
}
1414
@Override
1515
public String toString() {
1616
return "Burrito is "+ degree;
1717
}
1818
public static void main(String[] args) {
19-
System.out.println(new Burrito(NOT));
20-
System.out.println(new Burrito(MEDIUM));
21-
System.out.println(new Burrito(HOT));
19+
System.out.println(new Burrito2(NOT));
20+
System.out.println(new Burrito2(MEDIUM));
21+
System.out.println(new Burrito2(HOT));
2222
}
2323
}
2424
/* Output:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// enums/Spiciness.java
1+
// enums/SpicinessEnum.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55
package enums;
66

7-
public enum Spiciness {
7+
public enum SpicinessEnum {
88
NOT, MILD, MEDIUM, HOT, FLAMING
99
}

interfaces/Machine.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55
import java.util.*;
6-
import onjava.Operation;
6+
import onjava.Operations;
77

8-
class Bing implements Operation {
8+
class Bing implements Operations {
99
public void execute() {
10-
Operation.show("Bing");
10+
Operations.show("Bing");
1111
}
1212
}
1313

14-
class Crack implements Operation {
14+
class Crack implements Operations {
1515
public void execute() {
16-
Operation.show("Crack");
16+
Operations.show("Crack");
1717
}
1818
}
1919

20-
class Twist implements Operation {
20+
class Twist implements Operations {
2121
public void execute() {
22-
Operation.show("Twist");
22+
Operations.show("Twist");
2323
}
2424
}
2525

2626
public class Machine {
2727
public static void main(String[] args) {
28-
Operation.runOps(
28+
Operations.runOps(
2929
new Bing(), new Crack(), new Twist());
3030
}
3131
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// interfaces/RandomWords.java
1+
// interfaces/RandomStrings.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55
// Implementing an interface to conform to a method
66
import java.nio.*;
77
import java.util.*;
88

9-
public class RandomWords implements Readable {
9+
public class RandomStrings implements Readable {
1010
private static Random rand = new Random(47);
1111
private static final char[] CAPITALS =
1212
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
@@ -15,7 +15,7 @@ public class RandomWords implements Readable {
1515
private static final char[] VOWELS =
1616
"aeiou".toCharArray();
1717
private int count;
18-
public RandomWords(int count) { this.count = count; }
18+
public RandomStrings(int count) { this.count = count; }
1919
@Override
2020
public int read(CharBuffer cb) {
2121
if(count-- == 0)
@@ -29,7 +29,7 @@ public int read(CharBuffer cb) {
2929
return 10; // Number of characters appended
3030
}
3131
public static void main(String[] args) {
32-
Scanner s = new Scanner(new RandomWords(10));
32+
Scanner s = new Scanner(new RandomStrings(10));
3333
while(s.hasNext())
3434
System.out.println(s.next());
3535
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// onjava/Operation.java
1+
// onjava/Operations.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55
package onjava;
66
import java.util.*;
77

8-
public interface Operation {
8+
public interface Operations {
99
void execute();
10-
static void runOps(Operation... ops) {
11-
for(Operation op : ops)
10+
static void runOps(Operations... ops) {
11+
for(Operations op : ops)
1212
op.execute();
1313
}
1414
static void show(String msg) {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// reuse/SpaceShip.java
1+
// reuse/DerivedSpaceShip.java
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55

6-
public class SpaceShip extends SpaceShipControls {
6+
public class DerivedSpaceShip extends SpaceShipControls {
77
private String name;
8-
public SpaceShip(String name) { this.name = name; }
8+
public DerivedSpaceShip(String name) { this.name = name; }
99
@Override
1010
public String toString() { return name; }
1111
public static void main(String[] args) {
12-
SpaceShip protector = new SpaceShip("NSEA Protector");
12+
DerivedSpaceShip protector = new DerivedSpaceShip("NSEA Protector");
1313
protector.forward(100);
1414
}
1515
}

streams/Machine2.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55
import java.util.*;
6-
import onjava.Operation;
6+
import onjava.Operations;
77

88
public class Machine2 {
99
public static void main(String[] args) {
10-
Arrays.stream(new Operation[] {
11-
() -> Operation.show("Bing"),
12-
() -> Operation.show("Crack"),
13-
() -> Operation.show("Twist"),
14-
() -> Operation.show("Pop")
15-
}).forEach(Operation::execute);
10+
Arrays.stream(new Operations[] {
11+
() -> Operations.show("Bing"),
12+
() -> Operations.show("Crack"),
13+
() -> Operations.show("Twist"),
14+
() -> Operations.show("Pop")
15+
}).forEach(Operations::execute);
1616
}
1717
}
1818
/* Output:

typeinfo/Operation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Operation {
88
public final Supplier<String> description;
99
public final Runnable command;
1010
public
11-
Operation (Supplier<String> descr, Runnable cmd) {
11+
Operation(Supplier<String> descr, Runnable cmd) {
1212
description = descr;
1313
command = cmd;
1414
}

0 commit comments

Comments
 (0)