Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Adult",
"request": "launch",
"mainClass": "effectivejava.chapter2.item8.Adult",
"projectName": "effective-java-3e-source-code_616714c9"
},
{
"type": "java",
"name": "Run RomanNumerals with args",
"request": "launch",
"mainClass": "effectivejava.chapter2.item6.RomanNumerals",
"args": [
"5",
"1000"
]
},
{
"type": "java",
"name": "Run Sum with args",
"request": "launch",
"mainClass": "effectivejava.chapter2.item6.Sum",
"args": [
"1"
]
},
{
"type": "java",
"name": "Run Operation with args",
"request": "launch",
"mainClass": "effectivejava.chapter7.item42.Operation",
"args": [
"2",
"3"
]
}
]
}


2 changes: 1 addition & 1 deletion src/effectivejava/chapter2/item6/RomanNumerals.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void main(String[] args) {
for (int i = 0; i < numSets; i++) {
long start = System.nanoTime();
for (int j = 0; j < numReps; j++) {
b ^= isRomanNumeralSlow("MCMLXXVI"); // Change Slow to Fast to see performance difference
b ^= isRomanNumeralFast("MCMLXXVI"); // Change Slow to Fast to see performance difference
}
long end = System.nanoTime();
System.out.println(((end - start) / (1_000. * numReps)) + " μs.");
Expand Down
2 changes: 1 addition & 1 deletion src/effectivejava/chapter2/item6/Sum.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Hideously slow program! Can you spot the object creation? (Page 24)
public class Sum {
private static long sum() {
Long sum = 0L;
long sum = 0L;
for (long i = 0; i <= Integer.MAX_VALUE; i++)
sum += i;
return sum;
Expand Down