diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..c43b3684 --- /dev/null +++ b/.vscode/launch.json @@ -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" + ] + } +] +} + + diff --git a/src/effectivejava/chapter2/item6/RomanNumerals.java b/src/effectivejava/chapter2/item6/RomanNumerals.java index bf451409..8e0ad65c 100644 --- a/src/effectivejava/chapter2/item6/RomanNumerals.java +++ b/src/effectivejava/chapter2/item6/RomanNumerals.java @@ -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."); diff --git a/src/effectivejava/chapter2/item6/Sum.java b/src/effectivejava/chapter2/item6/Sum.java index 2a7a7ebd..9fd501be 100644 --- a/src/effectivejava/chapter2/item6/Sum.java +++ b/src/effectivejava/chapter2/item6/Sum.java @@ -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;