diff --git a/Copyright.txt b/Copyright.txt index 8fcd9b97..170a054b 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -1,5 +1,5 @@ -//: Copyright.txt -This computer source code is Copyright 2015 MindView LLC +// Copyright.txt +This computer source code is Copyright ©2015 MindView LLC All Rights Reserved. Permission to use, copy, modify, and distribute this @@ -70,4 +70,3 @@ where it is freely available under the terms stated above. If you think you've found an error in the Source Code, please submit a correction at: https://github.com/BruceEckel/OnJava-Examples/issues -///:~ diff --git a/annotations/AtUnitComposition.java b/annotations/AtUnitComposition.java index 604cbac7..796bd8ce 100644 --- a/annotations/AtUnitComposition.java +++ b/annotations/AtUnitComposition.java @@ -1,4 +1,4 @@ -//: annotations/AtUnitComposition.java +// annotations/AtUnitComposition.java // ©2015 MindView LLC: see Copyright.txt // Creating non-embedded tests. package annotations; @@ -18,9 +18,10 @@ public class AtUnitComposition { OSExecute.command( "java com.mindviewinc.atunit.AtUnit AtUnitComposition"); } -} /* Output: +} +/* Output: annotations.AtUnitComposition . _methodOne . _methodTwo This is methodTwo OK (2 tests) -*///:~ +*/ diff --git a/annotations/AtUnitExample1.java b/annotations/AtUnitExample1.java index f69c2bfa..3cf2d2f7 100644 --- a/annotations/AtUnitExample1.java +++ b/annotations/AtUnitExample1.java @@ -1,4 +1,4 @@ -//: annotations/AtUnitExample1.java +// annotations/AtUnitExample1.java // ©2015 MindView LLC: see Copyright.txt package annotations; import com.mindviewinc.atunit.*; @@ -24,7 +24,8 @@ public class AtUnitExample1 { OSExecute.command( "java com.mindviewinc.atunit.AtUnit AtUnitExample1"); } -} /* Output: +} +/* Output: annotations.AtUnitExample1 . anotherDisappointment (failed) . failureTest (failed) @@ -35,4 +36,4 @@ annotations.AtUnitExample1 >>> 2 FAILURES <<< annotations.AtUnitExample1: anotherDisappointment annotations.AtUnitExample1: failureTest -*///:~ +*/ diff --git a/annotations/AtUnitExample2.java b/annotations/AtUnitExample2.java index 2179c1c8..c463533f 100644 --- a/annotations/AtUnitExample2.java +++ b/annotations/AtUnitExample2.java @@ -1,4 +1,4 @@ -//: annotations/AtUnitExample2.java +// annotations/AtUnitExample2.java // ©2015 MindView LLC: see Copyright.txt // Assertions and exceptions can be used in @Tests. package annotations; @@ -32,7 +32,8 @@ public class AtUnitExample2 { OSExecute.command( "java com.mindviewinc.atunit.AtUnit AtUnitExample2"); } -} /* Output: +} +/* Output: annotations.AtUnitExample2 . assertFailureExample java.lang.AssertionError: What a surprise! @@ -46,4 +47,4 @@ nofile.txt (The system cannot find the file specified) >>> 2 FAILURES <<< annotations.AtUnitExample2: assertFailureExample annotations.AtUnitExample2: exceptionExample -*///:~ +*/ diff --git a/annotations/AtUnitExample3.java b/annotations/AtUnitExample3.java index e940dc6d..58b1a9de 100644 --- a/annotations/AtUnitExample3.java +++ b/annotations/AtUnitExample3.java @@ -1,4 +1,4 @@ -//: annotations/AtUnitExample3.java +// annotations/AtUnitExample3.java // ©2015 MindView LLC: see Copyright.txt package annotations; import com.mindviewinc.atunit.*; @@ -27,10 +27,11 @@ public class AtUnitExample3 { OSExecute.command( "java com.mindviewinc.atunit.AtUnit AtUnitExample3"); } -} /* Output: +} +/* Output: annotations.AtUnitExample3 . methodOneTest . initialization . m2 This is methodTwo OK (3 tests) -*///:~ +*/ diff --git a/annotations/AtUnitExample4.java b/annotations/AtUnitExample4.java index c6204170..566f0aef 100644 --- a/annotations/AtUnitExample4.java +++ b/annotations/AtUnitExample4.java @@ -1,4 +1,4 @@ -//: annotations/AtUnitExample4.java +// annotations/AtUnitExample4.java // ©2015 MindView LLC: see Copyright.txt package annotations; import java.util.*; @@ -58,7 +58,8 @@ public class AtUnitExample4 { OSExecute.command( "java com.mindviewinc.atunit.AtUnit AtUnitExample4"); } -} /* Output: +} +/* Output: starting annotations.AtUnitExample4 . scramble1 'All' @@ -67,4 +68,4 @@ lAl tsaeborornussu . words 'are' OK (3 tests) -*///:~ +*/ diff --git a/annotations/AtUnitExample5.java b/annotations/AtUnitExample5.java index 10bdaea7..45208b72 100644 --- a/annotations/AtUnitExample5.java +++ b/annotations/AtUnitExample5.java @@ -1,4 +1,4 @@ -//: annotations/AtUnitExample5.java +// annotations/AtUnitExample5.java // ©2015 MindView LLC: see Copyright.txt package annotations; import java.io.*; @@ -42,7 +42,8 @@ public class AtUnitExample5 { OSExecute.command( "java com.mindviewinc.atunit.AtUnit AtUnitExample5"); } -} /* Output: +} +/* Output: annotations.AtUnitExample5 . test3 Running cleanup @@ -51,4 +52,4 @@ Running cleanup . test2 Running cleanup OK (3 tests) -*///:~ +*/ diff --git a/annotations/AtUnitExternalTest.java b/annotations/AtUnitExternalTest.java index b0584a05..4390ac2e 100644 --- a/annotations/AtUnitExternalTest.java +++ b/annotations/AtUnitExternalTest.java @@ -1,4 +1,4 @@ -//: annotations/AtUnitExternalTest.java +// annotations/AtUnitExternalTest.java // ©2015 MindView LLC: see Copyright.txt // Creating non-embedded tests. package annotations; @@ -14,9 +14,10 @@ public class AtUnitExternalTest extends AtUnitExample1 { OSExecute.command( "java com.mindviewinc.atunit.AtUnit AtUnitExternalTest"); } -} /* Output: +} +/* Output: annotations.AtUnitExternalTest . _methodTwo This is methodTwo . _methodOne OK (2 tests) -*///:~ +*/ diff --git a/annotations/HashSetTest.java b/annotations/HashSetTest.java index 4bba5a49..381c1e09 100644 --- a/annotations/HashSetTest.java +++ b/annotations/HashSetTest.java @@ -1,4 +1,4 @@ -//: annotations/HashSetTest.java +// annotations/HashSetTest.java // ©2015 MindView LLC: see Copyright.txt package annotations; import java.util.*; @@ -23,10 +23,11 @@ public class HashSetTest { OSExecute.command( "java com.mindviewinc.atunit.AtUnit HashSetTest"); } -} /* Output: +} +/* Output: annotations.HashSetTest . initialization . _remove . _contains OK (3 tests) -*///:~ +*/ diff --git a/annotations/PasswordUtils.java b/annotations/PasswordUtils.java index 9961e749..95c74b9c 100644 --- a/annotations/PasswordUtils.java +++ b/annotations/PasswordUtils.java @@ -1,4 +1,4 @@ -//: annotations/PasswordUtils.java +// annotations/PasswordUtils.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -18,4 +18,4 @@ public class PasswordUtils { List prevPasswords, String password) { return !prevPasswords.contains(password); } -} ///:~ +} diff --git a/annotations/SimulatingNull.java b/annotations/SimulatingNull.java index c9f4002c..0944cc95 100644 --- a/annotations/SimulatingNull.java +++ b/annotations/SimulatingNull.java @@ -1,4 +1,4 @@ -//: annotations/SimulatingNull.java +// annotations/SimulatingNull.java // ©2015 MindView LLC: see Copyright.txt import java.lang.annotation.*; @@ -7,4 +7,4 @@ import java.lang.annotation.*; public @interface SimulatingNull { public int id() default -1; public String description() default ""; -} ///:~ +} diff --git a/annotations/StackL.java b/annotations/StackL.java index 542f537e..836c027f 100644 --- a/annotations/StackL.java +++ b/annotations/StackL.java @@ -1,4 +1,4 @@ -//: annotations/StackL.java +// annotations/StackL.java // ©2015 MindView LLC: see Copyright.txt // A stack built on a linkedList. package annotations; @@ -9,4 +9,4 @@ public class StackL { public void push(T v) { list.addFirst(v); } public T top() { return list.getFirst(); } public T pop() { return list.removeFirst(); } -} ///:~ +} diff --git a/annotations/StackLStringTest.java b/annotations/StackLStringTest.java index 39148068..d48bad63 100644 --- a/annotations/StackLStringTest.java +++ b/annotations/StackLStringTest.java @@ -1,4 +1,4 @@ -//: annotations/StackLStringTest.java +// annotations/StackLStringTest.java // ©2015 MindView LLC: see Copyright.txt // Applying @Unit to generics. package annotations; @@ -28,10 +28,11 @@ public class StackLStringTest extends StackL { OSExecute.command( "java com.mindviewinc.atunit.AtUnit StackLStringTest"); } -} /* Output: +} +/* Output: annotations.StackLStringTest . _push . _top . _pop OK (3 tests) -*///:~ +*/ diff --git a/annotations/Testable.java b/annotations/Testable.java index 6c9a60ea..4ef1ffbe 100644 --- a/annotations/Testable.java +++ b/annotations/Testable.java @@ -1,4 +1,4 @@ -//: annotations/Testable.java +// annotations/Testable.java // ©2015 MindView LLC: see Copyright.txt package annotations; import com.mindviewinc.atunit.*; @@ -8,4 +8,4 @@ public class Testable { System.out.println("Executing.."); } @Test void testExecute() { execute(); } -} ///:~ +} diff --git a/annotations/UseCase.java b/annotations/UseCase.java index 62f8eb82..7e2c0b78 100644 --- a/annotations/UseCase.java +++ b/annotations/UseCase.java @@ -1,4 +1,4 @@ -//: annotations/UseCase.java +// annotations/UseCase.java // ©2015 MindView LLC: see Copyright.txt import java.lang.annotation.*; @@ -7,4 +7,4 @@ import java.lang.annotation.*; public @interface UseCase { public int id(); public String description() default "no description"; -} ///:~ +} diff --git a/annotations/UseCaseTracker.java b/annotations/UseCaseTracker.java index 02f20f13..3bfcdcc3 100644 --- a/annotations/UseCaseTracker.java +++ b/annotations/UseCaseTracker.java @@ -1,4 +1,4 @@ -//: annotations/UseCaseTracker.java +// annotations/UseCaseTracker.java // ©2015 MindView LLC: see Copyright.txt import java.lang.reflect.*; import java.util.*; @@ -23,11 +23,12 @@ public class UseCaseTracker { Collections.addAll(useCases, 47, 48, 49, 50); trackUseCases(useCases, PasswordUtils.class); } -} /* Output: +} +/* Output: Found Use Case:49 New passwords can't equal previously used ones Found Use Case:47 Passwords must contain at least one numeric Found Use Case:48 no description Warning: Missing use case-50 -*///:~ +*/ diff --git a/annotations/database/Constraints.java b/annotations/database/Constraints.java index da7306b2..24b9bb33 100644 --- a/annotations/database/Constraints.java +++ b/annotations/database/Constraints.java @@ -1,4 +1,4 @@ -//: annotations/database/Constraints.java +// annotations/database/Constraints.java // ©2015 MindView LLC: see Copyright.txt package annotations.database; import java.lang.annotation.*; @@ -9,4 +9,4 @@ public @interface Constraints { boolean primaryKey() default false; boolean allowNull() default true; boolean unique() default false; -} ///:~ +} diff --git a/annotations/database/DBTable.java b/annotations/database/DBTable.java index 2245db87..80a84ac2 100644 --- a/annotations/database/DBTable.java +++ b/annotations/database/DBTable.java @@ -1,4 +1,4 @@ -//: annotations/database/DBTable.java +// annotations/database/DBTable.java // ©2015 MindView LLC: see Copyright.txt package annotations.database; import java.lang.annotation.*; @@ -7,4 +7,4 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) public @interface DBTable { public String name() default ""; -} ///:~ +} diff --git a/annotations/database/Member.java b/annotations/database/Member.java index 94ad722e..6b6de563 100644 --- a/annotations/database/Member.java +++ b/annotations/database/Member.java @@ -1,4 +1,4 @@ -//: annotations/database/Member.java +// annotations/database/Member.java // ©2015 MindView LLC: see Copyright.txt package annotations.database; @@ -17,4 +17,4 @@ public class Member { @Override public String toString() { return handle; } public Integer getAge() { return age; } -} ///:~ +} diff --git a/annotations/database/SQLInteger.java b/annotations/database/SQLInteger.java index f870f35d..2a719e3c 100644 --- a/annotations/database/SQLInteger.java +++ b/annotations/database/SQLInteger.java @@ -1,4 +1,4 @@ -//: annotations/database/SQLInteger.java +// annotations/database/SQLInteger.java // ©2015 MindView LLC: see Copyright.txt package annotations.database; import java.lang.annotation.*; @@ -8,4 +8,4 @@ import java.lang.annotation.*; public @interface SQLInteger { String name() default ""; Constraints constraints() default @Constraints; -} ///:~ +} diff --git a/annotations/database/SQLString.java b/annotations/database/SQLString.java index 4ea409d8..ccfd47ad 100644 --- a/annotations/database/SQLString.java +++ b/annotations/database/SQLString.java @@ -1,4 +1,4 @@ -//: annotations/database/SQLString.java +// annotations/database/SQLString.java // ©2015 MindView LLC: see Copyright.txt package annotations.database; import java.lang.annotation.*; @@ -9,4 +9,4 @@ public @interface SQLString { int value() default 0; String name() default ""; Constraints constraints() default @Constraints; -} ///:~ +} diff --git a/annotations/database/TableCreator.java b/annotations/database/TableCreator.java index a0dd8104..cbe6dfcf 100644 --- a/annotations/database/TableCreator.java +++ b/annotations/database/TableCreator.java @@ -1,4 +1,4 @@ -//: annotations/database/TableCreator.java +// annotations/database/TableCreator.java // ©2015 MindView LLC: see Copyright.txt // Reflection-based annotation processor. // {Args: annotations.database.Member} @@ -74,7 +74,8 @@ public class TableCreator { constraints += " UNIQUE"; return constraints; } -} /* Output: +} +/* Output: Table Creation SQL for annotations.database.Member is : CREATE TABLE MEMBER( FIRSTNAME VARCHAR(30)); @@ -93,4 +94,4 @@ CREATE TABLE MEMBER( LASTNAME VARCHAR(50), AGE INT, HANDLE VARCHAR(30) PRIMARY KEY); -*///:~ +*/ diff --git a/annotations/database/Uniqueness.java b/annotations/database/Uniqueness.java index 3a285612..b9df929c 100644 --- a/annotations/database/Uniqueness.java +++ b/annotations/database/Uniqueness.java @@ -1,4 +1,4 @@ -//: annotations/database/Uniqueness.java +// annotations/database/Uniqueness.java // ©2015 MindView LLC: see Copyright.txt // Sample of nested annotations package annotations.database; @@ -6,4 +6,4 @@ package annotations.database; public @interface Uniqueness { Constraints constraints() default @Constraints(unique=true); -} ///:~ +} diff --git a/annotations/ifx/ExtractInterface.java b/annotations/ifx/ExtractInterface.java index 296132f7..00d372fe 100644 --- a/annotations/ifx/ExtractInterface.java +++ b/annotations/ifx/ExtractInterface.java @@ -1,4 +1,4 @@ -//: annotations/ifx/ExtractInterface.java +// annotations/ifx/ExtractInterface.java // ©2015 MindView LLC: see Copyright.txt // javac-based annotation processing. package annotations.ifx; @@ -8,4 +8,4 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.SOURCE) public @interface ExtractInterface { public String interfaceName() default "-!!-"; -} ///:~ +} diff --git a/annotations/ifx/IfaceExtractorProcessor.java b/annotations/ifx/IfaceExtractorProcessor.java index 5a6a4669..22685498 100644 --- a/annotations/ifx/IfaceExtractorProcessor.java +++ b/annotations/ifx/IfaceExtractorProcessor.java @@ -1,4 +1,4 @@ -//: annotations/ifx/IfaceExtractorProcessor.java +// annotations/ifx/IfaceExtractorProcessor.java // ©2015 MindView LLC: see Copyright.txt // javac-based annotation processing. package annotations.ifx; @@ -89,4 +89,4 @@ extends AbstractProcessor { args += ")"; return args; } -} ///:~ +} diff --git a/annotations/ifx/Multiplier.java b/annotations/ifx/Multiplier.java index a11dbf81..b1eb28e9 100644 --- a/annotations/ifx/Multiplier.java +++ b/annotations/ifx/Multiplier.java @@ -1,4 +1,4 @@ -//: annotations/ifx/Multiplier.java +// annotations/ifx/Multiplier.java // ©2015 MindView LLC: see Copyright.txt // javac-based annotation processing. package annotations.ifx; @@ -25,6 +25,7 @@ public class Multiplier { System.out.println( "11 * 16 = " + m.multiply(11, 16)); } -} /* Output: +} +/* Output: 11 * 16 = 176 -*///:~ +*/ diff --git a/annotations/simplest/Simple.java b/annotations/simplest/Simple.java index 07889d3c..bbf83c0d 100644 --- a/annotations/simplest/Simple.java +++ b/annotations/simplest/Simple.java @@ -1,4 +1,4 @@ -//: annotations/simplest/Simple.java +// annotations/simplest/Simple.java // ©2015 MindView LLC: see Copyright.txt // A bare-bones annotation. package annotations.simplest; @@ -15,4 +15,4 @@ import java.lang.annotation.ElementType; ElementType.LOCAL_VARIABLE}) public @interface Simple { String value() default "-default-"; -} ///:~ +} diff --git a/annotations/simplest/SimpleProcessor.java b/annotations/simplest/SimpleProcessor.java index 0c24aace..97a3082c 100644 --- a/annotations/simplest/SimpleProcessor.java +++ b/annotations/simplest/SimpleProcessor.java @@ -1,4 +1,4 @@ -//: annotations/simplest/SimpleProcessor.java +// annotations/simplest/SimpleProcessor.java // ©2015 MindView LLC: see Copyright.txt // A bare-bones annotation processor. package annotations.simplest; @@ -41,4 +41,4 @@ extends AbstractProcessor { System.out.println(ex.getParameters() + ")"); } } -} ///:~ +} diff --git a/annotations/simplest/SimpleTest.java b/annotations/simplest/SimpleTest.java index ff9c4987..5f466f58 100644 --- a/annotations/simplest/SimpleTest.java +++ b/annotations/simplest/SimpleTest.java @@ -1,4 +1,4 @@ -//: annotations/simplest/SimpleTest.java +// annotations/simplest/SimpleTest.java // ©2015 MindView LLC: see Copyright.txt // Test the "Simple" annotation package annotations.simplest; @@ -23,6 +23,7 @@ public class SimpleTest { SimpleTest st = new SimpleTest(); st.foo(); } -} /* Output: +} +/* Output: SimpleTest.foo() -*///:~ +*/ diff --git a/arrays/AlphabeticSearch.java b/arrays/AlphabeticSearch.java index d4c1e0dd..7a93c0ce 100644 --- a/arrays/AlphabeticSearch.java +++ b/arrays/AlphabeticSearch.java @@ -1,4 +1,4 @@ -//: arrays/AlphabeticSearch.java +// arrays/AlphabeticSearch.java // ©2015 MindView LLC: see Copyright.txt // Searching with a Comparator. import java.util.*; @@ -14,11 +14,12 @@ public class AlphabeticSearch { String.CASE_INSENSITIVE_ORDER); System.out.println("Index: "+ index + "\n"+ sa[index]); } -} /* Output: +} +/* Output: [bkIna, cQrGs, cXZJo, dLsmw, eGZMm, EqUCB, gwsqP, hKcxr, HLGEa, HqXum, HxxHv, JMRoE, JmzMs, Mesbt, MNvqe, nyGcF, ogoYW, OneOE, OWZnT, RFJQA, rUkZP, sgqia, slJrL, suEcU, uTpnX, vpfFv, WHkjU, xxEAJ, YNzbr, zDyCy] Index: 10 HxxHv -*///:~ +*/ diff --git a/arrays/ArrayOfGenericType.java b/arrays/ArrayOfGenericType.java index 4db2beb2..9040133d 100644 --- a/arrays/ArrayOfGenericType.java +++ b/arrays/ArrayOfGenericType.java @@ -1,4 +1,4 @@ -//: arrays/ArrayOfGenericType.java +// arrays/ArrayOfGenericType.java // ©2015 MindView LLC: see Copyright.txt // Arrays of generic types won't compile. @@ -11,4 +11,4 @@ public class ArrayOfGenericType { } // Illegal: //! public U[] makeArray() { return new U[10]; } -} ///:~ +} diff --git a/arrays/ArrayOfGenerics.java b/arrays/ArrayOfGenerics.java index 4a75ba29..f7905efd 100644 --- a/arrays/ArrayOfGenerics.java +++ b/arrays/ArrayOfGenerics.java @@ -1,4 +1,4 @@ -//: arrays/ArrayOfGenerics.java +// arrays/ArrayOfGenerics.java // ©2015 MindView LLC: see Copyright.txt // It is possible to create arrays of generics. import java.util.*; @@ -26,4 +26,5 @@ public class ArrayOfGenerics { for(int i = 0; i < spheres.length; i++) spheres[i] = new ArrayList<>(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/arrays/ArrayOptions.java b/arrays/ArrayOptions.java index f47b9c13..78b7c0e8 100644 --- a/arrays/ArrayOptions.java +++ b/arrays/ArrayOptions.java @@ -1,4 +1,4 @@ -//: arrays/ArrayOptions.java +// arrays/ArrayOptions.java // ©2015 MindView LLC: see Copyright.txt // Initialization & re-assignment of arrays. import java.util.*; @@ -52,7 +52,8 @@ public class ArrayOptions { e = new int[]{ 1, 2 }; print("e.length = " + e.length); } -} /* Output: +} +/* Output: b: [null, null, null, null, null] a.length = 2 b.length = 5 @@ -65,4 +66,4 @@ g.length = 4 h.length = 3 e.length = 3 e.length = 2 -*///:~ +*/ diff --git a/arrays/ArraySearching.java b/arrays/ArraySearching.java index 68de1c9f..7d06c436 100644 --- a/arrays/ArraySearching.java +++ b/arrays/ArraySearching.java @@ -1,4 +1,4 @@ -//: arrays/ArraySearching.java +// arrays/ArraySearching.java // ©2015 MindView LLC: see Copyright.txt // Using Arrays.binarySearch(). import java.util.*; @@ -23,9 +23,10 @@ public class ArraySearching { } } } -} /* Output: +} +/* Output: Sorted array: [128, 140, 200, 207, 258, 258, 278, 288, 322, 429, 511, 520, 522, 551, 555, 589, 693, 704, 809, 861, 861, 868, 916, 961, 998] Location of 322 is 8, a[8] = 322 -*///:~ +*/ diff --git a/arrays/AssemblingMultidimensionalArrays.java b/arrays/AssemblingMultidimensionalArrays.java index 56adbbc1..37ef41cd 100644 --- a/arrays/AssemblingMultidimensionalArrays.java +++ b/arrays/AssemblingMultidimensionalArrays.java @@ -1,4 +1,4 @@ -//: arrays/AssemblingMultidimensionalArrays.java +// arrays/AssemblingMultidimensionalArrays.java // ©2015 MindView LLC: see Copyright.txt // Creating multidimensional arrays. import java.util.*; @@ -14,6 +14,7 @@ public class AssemblingMultidimensionalArrays { } System.out.println(Arrays.deepToString(a)); } -} /* Output: +} +/* Output: [[0, 0, 0], [0, 1, 2], [0, 2, 4]] -*///:~ +*/ diff --git a/arrays/AutoboxingArrays.java b/arrays/AutoboxingArrays.java index 4c472b98..ad296b1b 100644 --- a/arrays/AutoboxingArrays.java +++ b/arrays/AutoboxingArrays.java @@ -1,4 +1,4 @@ -//: arrays/AutoboxingArrays.java +// arrays/AutoboxingArrays.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -12,8 +12,9 @@ public class AutoboxingArrays { }; System.out.println(Arrays.deepToString(a)); } -} /* Output: +} +/* Output: [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]] -*///:~ +*/ diff --git a/arrays/CompType.java b/arrays/CompType.java index 1a08f1ec..2e3da661 100644 --- a/arrays/CompType.java +++ b/arrays/CompType.java @@ -1,4 +1,4 @@ -//: arrays/CompType.java +// arrays/CompType.java // ©2015 MindView LLC: see Copyright.txt // Implementing Comparable in a class. import java.util.*; @@ -27,7 +27,7 @@ public class CompType implements Comparable { private static Random r = new Random(47); public static Generator generator() { return () -> - new CompType(r.nextInt(100),r.nextInt(100)); + new CompType(r.nextInt(100), r.nextInt(100)); } public static void main(String[] args) { CompType[] a = @@ -38,7 +38,8 @@ public class CompType implements Comparable { print("after sorting:"); print(Arrays.toString(a)); } -} /* Output: +} +/* Output: before sorting: [[i = 58, j = 55], [i = 93, j = 61], [i = 61, j = 29] , [i = 68, j = 0], [i = 22, j = 7], [i = 88, j = 28] @@ -51,4 +52,4 @@ after sorting: , [i = 58, j = 55], [i = 61, j = 29], [i = 68, j = 0] , [i = 88, j = 28], [i = 93, j = 61], [i = 98, j = 61] ] -*///:~ +*/ diff --git a/arrays/ComparatorTest.java b/arrays/ComparatorTest.java index 13f087f1..a1f7313f 100644 --- a/arrays/ComparatorTest.java +++ b/arrays/ComparatorTest.java @@ -1,4 +1,4 @@ -//: arrays/ComparatorTest.java +// arrays/ComparatorTest.java // ©2015 MindView LLC: see Copyright.txt // Implementing a Comparator for a class. import java.util.*; @@ -21,7 +21,8 @@ public class ComparatorTest { print("after sorting:"); print(Arrays.toString(a)); } -} /* Output: +} +/* Output: before sorting: [[i = 58, j = 55], [i = 93, j = 61], [i = 61, j = 29] , [i = 68, j = 0], [i = 22, j = 7], [i = 88, j = 28] @@ -34,4 +35,4 @@ after sorting: , [i = 58, j = 55], [i = 20, j = 58], [i = 93, j = 61] , [i = 98, j = 61], [i = 9, j = 78], [i = 51, j = 89] ] -*///:~ +*/ diff --git a/arrays/ComparingArrays.java b/arrays/ComparingArrays.java index 0ec9fe37..63413d45 100644 --- a/arrays/ComparingArrays.java +++ b/arrays/ComparingArrays.java @@ -1,4 +1,4 @@ -//: arrays/ComparingArrays.java +// arrays/ComparingArrays.java // ©2015 MindView LLC: see Copyright.txt // Using Arrays.equals() import java.util.*; @@ -19,8 +19,9 @@ public class ComparingArrays { new String("Hi"), new String("Hi") }; print(Arrays.equals(s1, s2)); } -} /* Output: +} +/* Output: true false true -*///:~ +*/ diff --git a/arrays/ContainerComparison.java b/arrays/ContainerComparison.java index 536193d8..f073f452 100644 --- a/arrays/ContainerComparison.java +++ b/arrays/ContainerComparison.java @@ -1,4 +1,4 @@ -//: arrays/ContainerComparison.java +// arrays/ContainerComparison.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import static com.mindviewinc.util.Print.*; @@ -34,7 +34,8 @@ public class ContainerComparison { print(intList); print(intList.get(4)); } -} /* Output: +} +/* Output: [Sphere 0, Sphere 1, Sphere 2, Sphere 3, Sphere 4, null, null, null, null, null] Sphere 4 @@ -44,4 +45,4 @@ Sphere 9 4 [0, 1, 2, 3, 4, 5, 97] 4 -*///:~ +*/ diff --git a/arrays/CopyingArrays.java b/arrays/CopyingArrays.java index 507a666a..62ee5af8 100644 --- a/arrays/CopyingArrays.java +++ b/arrays/CopyingArrays.java @@ -1,4 +1,4 @@ -//: arrays/CopyingArrays.java +// arrays/CopyingArrays.java // ©2015 MindView LLC: see Copyright.txt // Using System.arraycopy() import java.util.*; @@ -31,7 +31,8 @@ public class CopyingArrays { System.arraycopy(v, 0, u, u.length/2, v.length); print("u = " + Arrays.toString(u)); } -} /* Output: +} +/* Output: i = [47, 47, 47, 47, 47, 47, 47] j = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99] j = [47, 47, 47, 47, 47, 47, 47, 99, 99, 99] @@ -40,4 +41,4 @@ i = [103, 103, 103, 103, 103, 47, 47] u = [47, 47, 47, 47, 47, 47, 47, 47, 47, 47] v = [99, 99, 99, 99, 99] u = [47, 47, 47, 47, 47, 99, 99, 99, 99, 99] -*///:~ +*/ diff --git a/arrays/FillingArrays.java b/arrays/FillingArrays.java index 5464e0de..d0d99181 100644 --- a/arrays/FillingArrays.java +++ b/arrays/FillingArrays.java @@ -1,4 +1,4 @@ -//: arrays/FillingArrays.java +// arrays/FillingArrays.java // ©2015 MindView LLC: see Copyright.txt // Using Arrays.fill() import java.util.*; @@ -38,7 +38,8 @@ public class FillingArrays { Arrays.fill(a9, 3, 5, "World"); print("a9 = " + Arrays.toString(a9)); } -} /* Output: +} +/* Output: a1 = [true, true, true, true, true, true] a2 = [11, 11, 11, 11, 11, 11] a3 = [x, x, x, x, x, x] @@ -49,4 +50,4 @@ a7 = [29.0, 29.0, 29.0, 29.0, 29.0, 29.0] a8 = [47.0, 47.0, 47.0, 47.0, 47.0, 47.0] a9 = [Hello, Hello, Hello, Hello, Hello, Hello] a9 = [Hello, Hello, Hello, World, World, Hello] -*///:~ +*/ diff --git a/arrays/GeneratorsTest.java b/arrays/GeneratorsTest.java index ab473d98..0d6be837 100644 --- a/arrays/GeneratorsTest.java +++ b/arrays/GeneratorsTest.java @@ -1,4 +1,4 @@ -//: arrays/GeneratorsTest.java +// arrays/GeneratorsTest.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -21,7 +21,8 @@ public class GeneratorsTest { public static void main(String[] args) { test(CountingGenerator.class); } -} /* Output: +} +/* Output: Double: 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 Float: 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 Long: 0 1 2 3 4 5 6 7 8 9 @@ -33,4 +34,4 @@ Character: a b c d e f g h i j Byte: 0 1 2 3 4 5 6 7 8 9 Boolean: true false true false true false true false true false -*///:~ +*/ diff --git a/arrays/IceCream.java b/arrays/IceCream.java index 3fc3f501..c923ddc0 100644 --- a/arrays/IceCream.java +++ b/arrays/IceCream.java @@ -1,4 +1,4 @@ -//: arrays/IceCream.java +// arrays/IceCream.java // ©2015 MindView LLC: see Copyright.txt // Returning arrays from methods. import java.util.*; @@ -29,7 +29,8 @@ public class IceCream { for(int i = 0; i < 7; i++) System.out.println(Arrays.toString(flavorSet(3))); } -} /* Output: +} +/* Output: [Rum Raisin, Mint Chip, Mocha Almond Fudge] [Chocolate, Strawberry, Mocha Almond Fudge] [Strawberry, Mint Chip, Mocha Almond Fudge] @@ -37,4 +38,4 @@ public class IceCream { [Vanilla Fudge Swirl, Chocolate, Mocha Almond Fudge] [Praline Cream, Strawberry, Mocha Almond Fudge] [Mocha Almond Fudge, Strawberry, Mint Chip] -*///:~ +*/ diff --git a/arrays/MultiDimWrapperArray.java b/arrays/MultiDimWrapperArray.java index 1b853ef3..eb87084e 100644 --- a/arrays/MultiDimWrapperArray.java +++ b/arrays/MultiDimWrapperArray.java @@ -1,4 +1,4 @@ -//: arrays/MultiDimWrapperArray.java +// arrays/MultiDimWrapperArray.java // ©2015 MindView LLC: see Copyright.txt // Multidimensional arrays of "wrapper" objects. import java.util.*; @@ -23,10 +23,11 @@ public class MultiDimWrapperArray { System.out.println("a2: " + Arrays.deepToString(a2)); System.out.println("a3: " + Arrays.deepToString(a3)); } -} /* Output: +} +/* Output: a1: [[1, 2, 3], [4, 5, 6]] a2: [[[1.1, 2.2], [3.3, 4.4]], [[5.5, 6.6], [7.7, 8.8]], [[9.9, 1.2], [2.3, 3.4]]] a3: [[The, Quick, Sly, Fox], [Jumped, Over], [The, Lazy, Brown, Dog, and, friend]] -*///:~ +*/ diff --git a/arrays/MultidimensionalObjectArrays.java b/arrays/MultidimensionalObjectArrays.java index 2504101e..58a950c2 100644 --- a/arrays/MultidimensionalObjectArrays.java +++ b/arrays/MultidimensionalObjectArrays.java @@ -1,4 +1,4 @@ -//: arrays/MultidimensionalObjectArrays.java +// arrays/MultidimensionalObjectArrays.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -15,8 +15,9 @@ public class MultidimensionalObjectArrays { }; System.out.println(Arrays.deepToString(spheres)); } -} /* Output: +} +/* Output: [[Sphere 0, Sphere 1], [Sphere 2, Sphere 3, Sphere 4, Sphere 5], [Sphere 6, Sphere 7, Sphere 8, Sphere 9, Sphere 10, Sphere 11, Sphere 12, Sphere 13]] -*///:~ +*/ diff --git a/arrays/MultidimensionalPrimitiveArray.java b/arrays/MultidimensionalPrimitiveArray.java index 801dded9..8e83d4b5 100644 --- a/arrays/MultidimensionalPrimitiveArray.java +++ b/arrays/MultidimensionalPrimitiveArray.java @@ -1,4 +1,4 @@ -//: arrays/MultidimensionalPrimitiveArray.java +// arrays/MultidimensionalPrimitiveArray.java // ©2015 MindView LLC: see Copyright.txt // Creating multidimensional arrays. import java.util.*; @@ -11,6 +11,7 @@ public class MultidimensionalPrimitiveArray { }; System.out.println(Arrays.deepToString(a)); } -} /* Output: +} +/* Output: [[1, 2, 3], [4, 5, 6]] -*///:~ +*/ diff --git a/arrays/ParameterizedArrayType.java b/arrays/ParameterizedArrayType.java index 5c786243..ac284ae8 100644 --- a/arrays/ParameterizedArrayType.java +++ b/arrays/ParameterizedArrayType.java @@ -1,4 +1,4 @@ -//: arrays/ParameterizedArrayType.java +// arrays/ParameterizedArrayType.java // ©2015 MindView LLC: see Copyright.txt class ClassParameter { @@ -20,4 +20,5 @@ public class ParameterizedArrayType { ints2 = MethodParameter.f(ints); doubles2 = MethodParameter.f(doubles); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/arrays/PrimitiveConversionDemonstration.java b/arrays/PrimitiveConversionDemonstration.java index 87d1c371..16f0246f 100644 --- a/arrays/PrimitiveConversionDemonstration.java +++ b/arrays/PrimitiveConversionDemonstration.java @@ -1,4 +1,4 @@ -//: arrays/PrimitiveConversionDemonstration.java +// arrays/PrimitiveConversionDemonstration.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import com.mindviewinc.util.*; @@ -14,7 +14,8 @@ public class PrimitiveConversionDemonstration { new CountingGenerator.Boolean(), 7)); System.out.println(Arrays.toString(c)); } -} /* Output: +} +/* Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] [true, false, true, false, true, false, true] -*///:~ +*/ diff --git a/arrays/PythonLists.py b/arrays/PythonLists.py index 70b00972..bee1fe31 100644 --- a/arrays/PythonLists.py +++ b/arrays/PythonLists.py @@ -1,4 +1,4 @@ -#: arrays/PythonLists.py +# arrays/PythonLists.py # ©2015 MindView LLC: see Copyright.txt aList = [1, 2, 3, 4, 5] @@ -22,4 +22,4 @@ class MyList(list): # Inherit from list list2 = MyList(aList) print(type(list2)) # print(list2.getReversed()) # [8, 7, 6, 5, 4, 3, 2, 1] -#:~ +#> diff --git a/arrays/RaggedArray.java b/arrays/RaggedArray.java index c4ebd0b9..9f1849ed 100644 --- a/arrays/RaggedArray.java +++ b/arrays/RaggedArray.java @@ -1,4 +1,4 @@ -//: arrays/RaggedArray.java +// arrays/RaggedArray.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -14,8 +14,9 @@ public class RaggedArray { } System.out.println(Arrays.deepToString(a)); } -} /* Output: +} +/* Output: [[], [[0], [0], [0, 0, 0, 0]], [[], [0, 0], [0, 0]], [[0, 0, 0], [0], [0, 0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0], []], [[0], [], [0]]] -*///:~ +*/ diff --git a/arrays/RandomGeneratorsTest.java b/arrays/RandomGeneratorsTest.java index bb17df61..1bc982eb 100644 --- a/arrays/RandomGeneratorsTest.java +++ b/arrays/RandomGeneratorsTest.java @@ -1,4 +1,4 @@ -//: arrays/RandomGeneratorsTest.java +// arrays/RandomGeneratorsTest.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -6,7 +6,8 @@ public class RandomGeneratorsTest { public static void main(String[] args) { GeneratorsTest.test(RandomGenerator.class); } -} /* Output: +} +/* Output: Double: 0.73 0.53 0.16 0.19 0.52 0.27 0.26 0.05 0.8 0.76 Float: 0.53 0.16 0.53 0.4 0.49 0.25 0.8 0.11 0.02 0.8 Long: 7674 8804 8950 7826 4322 896 8033 2984 2344 5810 @@ -19,4 +20,4 @@ Character: x x E A J J m z M s Byte: -60 -17 55 -14 -5 115 39 -37 79 115 Boolean: false true false false true true true true true true -*///:~ +*/ diff --git a/arrays/Reverse.java b/arrays/Reverse.java index 0950876a..dbaec2f2 100644 --- a/arrays/Reverse.java +++ b/arrays/Reverse.java @@ -1,4 +1,4 @@ -//: arrays/Reverse.java +// arrays/Reverse.java // ©2015 MindView LLC: see Copyright.txt // The Collections.reverseOrder() Comparator import java.util.*; @@ -15,7 +15,8 @@ public class Reverse { print("after sorting:"); print(Arrays.toString(a)); } -} /* Output: +} +/* Output: before sorting: [[i = 58, j = 55], [i = 93, j = 61], [i = 61, j = 29] , [i = 68, j = 0], [i = 22, j = 7], [i = 88, j = 28] @@ -28,4 +29,4 @@ after sorting: , [i = 51, j = 89], [i = 22, j = 7], [i = 20, j = 58] , [i = 16, j = 40], [i = 11, j = 22], [i = 9, j = 78] ] -*///:~ +*/ diff --git a/arrays/StringSorting.java b/arrays/StringSorting.java index aabf8e79..bed6bc13 100644 --- a/arrays/StringSorting.java +++ b/arrays/StringSorting.java @@ -1,4 +1,4 @@ -//: arrays/StringSorting.java +// arrays/StringSorting.java // ©2015 MindView LLC: see Copyright.txt // Sorting an array of Strings. import java.util.*; @@ -17,7 +17,8 @@ public class StringSorting { Arrays.sort(sa, String.CASE_INSENSITIVE_ORDER); print("Case-insensitive sort: " + Arrays.toString(sa)); } -} /* Output: +} +/* Output: Before sort: [YNzbr, nyGcF, OWZnT, cQrGs, eGZMm, JMRoE, suEcU, OneOE, dLsmw, HLGEa, hKcxr, EqUCB, bkIna, Mesbt, WHkjU, rUkZP, gwsqP, zDyCy, RFJQA, HxxHv] @@ -30,4 +31,4 @@ OWZnT, Mesbt, JMRoE, HxxHv, HLGEa, EqUCB] Case-insensitive sort: [bkIna, cQrGs, dLsmw, eGZMm, EqUCB, gwsqP, hKcxr, HLGEa, HxxHv, JMRoE, Mesbt, nyGcF, OneOE, OWZnT, RFJQA, rUkZP, suEcU, WHkjU, YNzbr, zDyCy] -*///:~ +*/ diff --git a/arrays/TestArrayGeneration.java b/arrays/TestArrayGeneration.java index 7963003d..1265bd7c 100644 --- a/arrays/TestArrayGeneration.java +++ b/arrays/TestArrayGeneration.java @@ -1,4 +1,4 @@ -//: arrays/TestArrayGeneration.java +// arrays/TestArrayGeneration.java // ©2015 MindView LLC: see Copyright.txt // Test the tools that use generators to fill arrays. import java.util.*; @@ -34,7 +34,8 @@ public class TestArrayGeneration { Double.class, new RandomGenerator.Double(), size)); print("a8 = " + Arrays.toString(a8)); } -} /* Output: +} +/* Output: a1 = [true, false, true, false, false, true] a2 = [104, -79, -76, 126, 33, -64] a3 = [Z, n, T, c, Q, r] @@ -43,4 +44,4 @@ a5 = [7704, 7383, 7706, 575, 8410, 6342] a6 = [7674, 8804, 8950, 7826, 4322, 896] a7 = [0.01, 0.2, 0.4, 0.79, 0.27, 0.45] a8 = [0.16, 0.87, 0.7, 0.66, 0.87, 0.59] -*///:~ +*/ diff --git a/arrays/TestGenerated.java b/arrays/TestGenerated.java index 00ccc618..b51ab08a 100644 --- a/arrays/TestGenerated.java +++ b/arrays/TestGenerated.java @@ -1,4 +1,4 @@ -//: arrays/TestGenerated.java +// arrays/TestGenerated.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import com.mindviewinc.util.*; @@ -7,14 +7,15 @@ public class TestGenerated { public static void main(String[] args) { Integer[] a = { 9, 8, 7, 6 }; System.out.println(Arrays.toString(a)); - a = Generated.array(a,new CountingGenerator.Integer()); + a = Generated.array(a, new CountingGenerator.Integer()); System.out.println(Arrays.toString(a)); Integer[] b = Generated.array(Integer.class, new CountingGenerator.Integer(), 15); System.out.println(Arrays.toString(b)); } -} /* Output: +} +/* Output: [9, 8, 7, 6] [0, 1, 2, 3] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] -*///:~ +*/ diff --git a/arrays/ThreeDWithNew.java b/arrays/ThreeDWithNew.java index 1329873c..d18d4e54 100644 --- a/arrays/ThreeDWithNew.java +++ b/arrays/ThreeDWithNew.java @@ -1,4 +1,4 @@ -//: arrays/ThreeDWithNew.java +// arrays/ThreeDWithNew.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -8,7 +8,8 @@ public class ThreeDWithNew { int[][][] a = new int[2][2][4]; System.out.println(Arrays.deepToString(a)); } -} /* Output: +} +/* Output: [[[0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0, 0]]] -*///:~ +*/ diff --git a/assertions/Assert1.java b/assertions/Assert1.java index e6fbfe2a..dab883f4 100644 --- a/assertions/Assert1.java +++ b/assertions/Assert1.java @@ -1,4 +1,4 @@ -//: assertions/Assert1.java +// assertions/Assert1.java // ©2015 MindView LLC: see Copyright.txt // Non-informative style of assert // {JVMArgs: -ea} // Must run with -ea @@ -8,9 +8,10 @@ public class Assert1 { public static void main(String[] args) { assert false; } -} /* Output: +} +/* Output: ___[ Error Output ]___ Exception in thread "main" java.lang.AssertionError at Assert1.main(Assert1.java:8) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/assertions/Assert2.java b/assertions/Assert2.java index 6e19cbed..1deeae2e 100644 --- a/assertions/Assert2.java +++ b/assertions/Assert2.java @@ -1,4 +1,4 @@ -//: assertions/Assert2.java +// assertions/Assert2.java // ©2015 MindView LLC: see Copyright.txt // Assert with an informative message // {JVMArgs: -ea} @@ -8,10 +8,11 @@ public class Assert2 { public static void main(String[] args) { assert false: "Here's a message saying what happened"; } -} /* Output: +} +/* Output: ___[ Error Output ]___ Exception in thread "main" java.lang.AssertionError: Here's a message saying what happened at Assert2.main(Assert2.java:8) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/assertions/LoaderAssertions.java b/assertions/LoaderAssertions.java index f89a95d7..3a4a3b15 100644 --- a/assertions/LoaderAssertions.java +++ b/assertions/LoaderAssertions.java @@ -1,4 +1,4 @@ -//: assertions/LoaderAssertions.java +// assertions/LoaderAssertions.java // ©2015 MindView LLC: see Copyright.txt // Using the class loader to enable assertions // {ThrowsException} @@ -15,11 +15,12 @@ class Loaded { public void go() { assert false: "Loaded.go()"; } -} /* Output: +} +/* Output: ___[ Error Output ]___ Exception in thread "main" java.lang.AssertionError: Loaded.go() at Loaded.go(LoaderAssertions.java:15) at LoaderAssertions.main(LoaderAssertions.java:9) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/assertions/Queue.java b/assertions/Queue.java index efc429f2..62b1ddb8 100644 --- a/assertions/Queue.java +++ b/assertions/Queue.java @@ -1,4 +1,4 @@ -//: assertions/Queue.java +// assertions/Queue.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of Design by Contract (DbC) combined // with white-box unit testing. @@ -177,7 +177,8 @@ public class Queue { org.junit.runner.JUnitCore.runClasses( Queue.WhiteBoxTest.class); } -} /* Output: +} +/* Output: testNullPut put() null item testCircularity @@ -229,4 +230,4 @@ get() from empty Queue in = 5, out = 5, full() = false, empty() = true, queue = [null, null, null, null, null, null, null, null, null, null] -*///:~ +*/ diff --git a/com/mindviewinc/atunit/AtUnit.java b/com/mindviewinc/atunit/AtUnit.java index d5d6511c..5ffed3bc 100644 --- a/com/mindviewinc/atunit/AtUnit.java +++ b/com/mindviewinc/atunit/AtUnit.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/atunit/AtUnit.java +// com/mindviewinc/atunit/AtUnit.java // ©2015 MindView LLC: see Copyright.txt // An annotation-based unit-test framework. package com.mindviewinc.atunit; @@ -156,6 +156,7 @@ public class AtUnit implements ProcessFiles.Strategy { } } } -} /* Output: +} +/* Output: OK (0 tests) -*///:~ +*/ diff --git a/com/mindviewinc/atunit/ClassNameFinder.java b/com/mindviewinc/atunit/ClassNameFinder.java index fccb6454..288bafac 100644 --- a/com/mindviewinc/atunit/ClassNameFinder.java +++ b/com/mindviewinc/atunit/ClassNameFinder.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/atunit/ClassNameFinder.java +// com/mindviewinc/atunit/ClassNameFinder.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.atunit; import java.io.*; @@ -73,7 +73,8 @@ public class ClassNameFinder { for(File klass : Directory.walk(".", ".*\\.class")) print(thisClass(BinaryFile.read(klass))); } -} /* Output: +} +/* Output: com.mindviewinc.atunit.AtUnit$TestMethods com.mindviewinc.atunit.AtUnit com.mindviewinc.atunit.ClassNameFinder @@ -81,4 +82,4 @@ com.mindviewinc.atunit.Test com.mindviewinc.atunit.TestObjectCleanup com.mindviewinc.atunit.TestObjectCreate com.mindviewinc.atunit.TestProperty -*///:~ +*/ diff --git a/com/mindviewinc/atunit/Test.java b/com/mindviewinc/atunit/Test.java index d23e9b8f..47014cfc 100644 --- a/com/mindviewinc/atunit/Test.java +++ b/com/mindviewinc/atunit/Test.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/atunit/Test.java +// com/mindviewinc/atunit/Test.java // ©2015 MindView LLC: see Copyright.txt // The @Test tag. package com.mindviewinc.atunit; @@ -6,4 +6,4 @@ import java.lang.annotation.*; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) -public @interface Test {} ///:~ +public @interface Test {} diff --git a/com/mindviewinc/atunit/TestObjectCleanup.java b/com/mindviewinc/atunit/TestObjectCleanup.java index bcb095fe..4ce44ab8 100644 --- a/com/mindviewinc/atunit/TestObjectCleanup.java +++ b/com/mindviewinc/atunit/TestObjectCleanup.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/atunit/TestObjectCleanup.java +// com/mindviewinc/atunit/TestObjectCleanup.java // ©2015 MindView LLC: see Copyright.txt // The @Unit @TestObjectCleanup tag. package com.mindviewinc.atunit; @@ -6,4 +6,4 @@ import java.lang.annotation.*; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) -public @interface TestObjectCleanup {} ///:~ +public @interface TestObjectCleanup {} diff --git a/com/mindviewinc/atunit/TestObjectCreate.java b/com/mindviewinc/atunit/TestObjectCreate.java index 0a870a75..c136748f 100644 --- a/com/mindviewinc/atunit/TestObjectCreate.java +++ b/com/mindviewinc/atunit/TestObjectCreate.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/atunit/TestObjectCreate.java +// com/mindviewinc/atunit/TestObjectCreate.java // ©2015 MindView LLC: see Copyright.txt // The @Unit @TestObjectCreate tag. package com.mindviewinc.atunit; @@ -6,4 +6,4 @@ import java.lang.annotation.*; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) -public @interface TestObjectCreate {} ///:~ +public @interface TestObjectCreate {} diff --git a/com/mindviewinc/atunit/TestProperty.java b/com/mindviewinc/atunit/TestProperty.java index 43c95e2b..88c8eef3 100644 --- a/com/mindviewinc/atunit/TestProperty.java +++ b/com/mindviewinc/atunit/TestProperty.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/atunit/TestProperty.java +// com/mindviewinc/atunit/TestProperty.java // ©2015 MindView LLC: see Copyright.txt // The @Unit @TestProperty tag. package com.mindviewinc.atunit; @@ -7,4 +7,4 @@ import java.lang.annotation.*; // Both fields and methods can be tagged as properties: @Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface TestProperty {} ///:~ +public @interface TestProperty {} diff --git a/com/mindviewinc/simple/List.java b/com/mindviewinc/simple/List.java index 9840d90b..28b13c0f 100644 --- a/com/mindviewinc/simple/List.java +++ b/com/mindviewinc/simple/List.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/simple/List.java +// com/mindviewinc/simple/List.java // ©2015 MindView LLC: see Copyright.txt // Creating a package. package com.mindviewinc.simple; @@ -7,4 +7,4 @@ public class List { public List() { System.out.println("com.mindviewinc.simple.List"); } -} ///:~ +} diff --git a/com/mindviewinc/simple/Vector.java b/com/mindviewinc/simple/Vector.java index b5ff7f59..26eef911 100644 --- a/com/mindviewinc/simple/Vector.java +++ b/com/mindviewinc/simple/Vector.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/simple/Vector.java +// com/mindviewinc/simple/Vector.java // ©2015 MindView LLC: see Copyright.txt // Creating a package. package com.mindviewinc.simple; @@ -7,4 +7,4 @@ public class Vector { public Vector() { System.out.println("com.mindviewinc.simple.Vector"); } -} ///:~ +} diff --git a/com/mindviewinc/util/BasicGenerator.java b/com/mindviewinc/util/BasicGenerator.java index b4c94ff7..be6ae979 100644 --- a/com/mindviewinc/util/BasicGenerator.java +++ b/com/mindviewinc/util/BasicGenerator.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/BasicGenerator.java +// com/mindviewinc/util/BasicGenerator.java // ©2015 MindView LLC: see Copyright.txt // Automatically create a Generator, given a class // with a default (no-arg) constructor. @@ -21,4 +21,4 @@ public class BasicGenerator implements Generator { public static Generator create(Class type) { return new BasicGenerator<>(type); } -} ///:~ +} diff --git a/com/mindviewinc/util/BinaryFile.java b/com/mindviewinc/util/BinaryFile.java index 0755d301..b21698fd 100644 --- a/com/mindviewinc/util/BinaryFile.java +++ b/com/mindviewinc/util/BinaryFile.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/BinaryFile.java +// com/mindviewinc/util/BinaryFile.java // ©2015 MindView LLC: see Copyright.txt // Utility for reading files in binary form. package com.mindviewinc.util; @@ -17,4 +17,4 @@ public class BinaryFile { read(String bFile) throws IOException { return read(new File(bFile).getAbsoluteFile()); } -} ///:~ +} diff --git a/com/mindviewinc/util/CollectionData.java b/com/mindviewinc/util/CollectionData.java index cb623da6..6cd4c62b 100644 --- a/com/mindviewinc/util/CollectionData.java +++ b/com/mindviewinc/util/CollectionData.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/CollectionData.java +// com/mindviewinc/util/CollectionData.java // ©2015 MindView LLC: see Copyright.txt // A Collection filled with data using a generator object. package com.mindviewinc.util; @@ -14,4 +14,4 @@ public class CollectionData extends ArrayList { list(Generator gen, int quantity) { return new CollectionData<>(gen, quantity); } -} ///:~ +} diff --git a/com/mindviewinc/util/ContainerMethodDifferences.java b/com/mindviewinc/util/ContainerMethodDifferences.java index 25e88881..a978143b 100644 --- a/com/mindviewinc/util/ContainerMethodDifferences.java +++ b/com/mindviewinc/util/ContainerMethodDifferences.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/ContainerMethodDifferences.java +// com/mindviewinc/util/ContainerMethodDifferences.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; import java.lang.reflect.*; @@ -50,7 +50,8 @@ public class ContainerMethodDifferences { difference(SortedMap.class, Map.class); difference(TreeMap.class, Map.class); } -} /* Output: +} +/* Output: Collection: [add, addAll, clear, contains, containsAll, equals, forEach, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, @@ -105,4 +106,4 @@ pollFirstEntry, lastKey, firstEntry, floorEntry, comparator, lastEntry] Interfaces in TreeMap: [NavigableMap, Cloneable, Serializable] -*///:~ +*/ diff --git a/com/mindviewinc/util/ConvertTo.java b/com/mindviewinc/util/ConvertTo.java index 264d5107..93981d4e 100644 --- a/com/mindviewinc/util/ConvertTo.java +++ b/com/mindviewinc/util/ConvertTo.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/ConvertTo.java +// com/mindviewinc/util/ConvertTo.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; @@ -51,4 +51,4 @@ public class ConvertTo { result[i] = in[i]; return result; } -} ///:~ +} diff --git a/com/mindviewinc/util/CountingGenerator.java b/com/mindviewinc/util/CountingGenerator.java index 9b601499..397ebeb6 100644 --- a/com/mindviewinc/util/CountingGenerator.java +++ b/com/mindviewinc/util/CountingGenerator.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/CountingGenerator.java +// com/mindviewinc/util/CountingGenerator.java // ©2015 MindView LLC: see Copyright.txt // Simple generator implementations. package com.mindviewinc.util; @@ -82,4 +82,4 @@ public class CountingGenerator { return result; } } -} ///:~ +} diff --git a/com/mindviewinc/util/CountingIntegerList.java b/com/mindviewinc/util/CountingIntegerList.java index 7be5dec6..ee10001b 100644 --- a/com/mindviewinc/util/CountingIntegerList.java +++ b/com/mindviewinc/util/CountingIntegerList.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/CountingIntegerList.java +// com/mindviewinc/util/CountingIntegerList.java // ©2015 MindView LLC: see Copyright.txt // List of any length, containing sample data. package com.mindviewinc.util; @@ -19,7 +19,8 @@ extends AbstractList { public static void main(String[] args) { System.out.println(new CountingIntegerList(30)); } -} /* Output: +} +/* Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] -*///:~ +*/ diff --git a/com/mindviewinc/util/CountingMapData.java b/com/mindviewinc/util/CountingMapData.java index d6baa2b6..bdccd835 100644 --- a/com/mindviewinc/util/CountingMapData.java +++ b/com/mindviewinc/util/CountingMapData.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/CountingMapData.java +// com/mindviewinc/util/CountingMapData.java // ©2015 MindView LLC: see Copyright.txt // Unlimited-length Map containing sample data. package com.mindviewinc.util; @@ -51,7 +51,8 @@ extends AbstractMap { public static void main(String[] args) { System.out.println(new CountingMapData(60)); } -} /* Output: +} +/* Output: {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0, 9=J0, 10=K0, 11=L0, 12=M0, 13=N0, 14=O0, 15=P0, 16=Q0, 17=R0, 18=S0, 19=T0, 20=U0, 21=V0, 22=W0, 23=X0, 24=Y0, @@ -60,4 +61,4 @@ extends AbstractMap { 41=P1, 42=Q1, 43=R1, 44=S1, 45=T1, 46=U1, 47=V1, 48=W1, 49=X1, 50=Y1, 51=Z1, 52=A2, 53=B2, 54=C2, 55=D2, 56=E2, 57=F2, 58=G2, 59=H2} -*///:~ +*/ diff --git a/com/mindviewinc/util/Countries.java b/com/mindviewinc/util/Countries.java index ecb16a7f..67e4d597 100644 --- a/com/mindviewinc/util/Countries.java +++ b/com/mindviewinc/util/Countries.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Countries.java +// com/mindviewinc/util/Countries.java // ©2015 MindView LLC: see Copyright.txt // "Flyweight" Maps and Lists of sample data. package com.mindviewinc.util; @@ -239,7 +239,8 @@ public class Countries { print(new LinkedList<>(names(6))); print(capitals().get("BRAZIL")); } -} /* Output: +} +/* Output: {ALGERIA=Algiers, ANGOLA=Luanda, BENIN=Porto-Novo, BOTSWANA=Gaberone, BURKINA FASO=Ouagadougou, BURUNDI=Bujumbura, CAMEROON=Yaounde, CAPE VERDE=Praia, @@ -256,4 +257,4 @@ CAMEROON, CAPE VERDE, CENTRAL AFRICAN REPUBLIC, CHAD] [ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI] [ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI] Brasilia -*///:~ +*/ diff --git a/com/mindviewinc/util/DaemonThreadFactory.java b/com/mindviewinc/util/DaemonThreadFactory.java index 99ddfba3..82f892dc 100644 --- a/com/mindviewinc/util/DaemonThreadFactory.java +++ b/com/mindviewinc/util/DaemonThreadFactory.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/DaemonThreadFactory.java +// com/mindviewinc/util/DaemonThreadFactory.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; import java.util.concurrent.*; @@ -10,4 +10,4 @@ public class DaemonThreadFactory implements ThreadFactory { t.setDaemon(true); return t; } -} ///:~ +} diff --git a/com/mindviewinc/util/DaemonThreadPoolExecutor.java b/com/mindviewinc/util/DaemonThreadPoolExecutor.java index 5e12e7e4..6cb43f76 100644 --- a/com/mindviewinc/util/DaemonThreadPoolExecutor.java +++ b/com/mindviewinc/util/DaemonThreadPoolExecutor.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/DaemonThreadPoolExecutor.java +// com/mindviewinc/util/DaemonThreadPoolExecutor.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; import java.util.concurrent.*; @@ -10,4 +10,4 @@ extends ThreadPoolExecutor { new SynchronousQueue<>(), new DaemonThreadFactory()); } -} ///:~ +} diff --git a/com/mindviewinc/util/Deque.java b/com/mindviewinc/util/Deque.java index af48afd0..0462e309 100644 --- a/com/mindviewinc/util/Deque.java +++ b/com/mindviewinc/util/Deque.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Deque.java +// com/mindviewinc/util/Deque.java // ©2015 MindView LLC: see Copyright.txt // Creating a Deque from a LinkedList. package com.mindviewinc.util; @@ -16,4 +16,4 @@ public class Deque { @Override public String toString() { return deque.toString(); } // And other methods as necessary... -} ///:~ +} diff --git a/com/mindviewinc/util/Directory.java b/com/mindviewinc/util/Directory.java index baf67773..0c9901dc 100644 --- a/com/mindviewinc/util/Directory.java +++ b/com/mindviewinc/util/Directory.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Directory.java +// com/mindviewinc/util/Directory.java // ©2015 MindView LLC: see Copyright.txt // Produce a sequence of File objects that match a // regular expression in either a local directory, @@ -77,7 +77,8 @@ public final class Directory { for(String arg : args) System.out.println(walk(arg)); } -} /* Output: (First 20 Lines) +} +/* Output: (First 20 Lines) dirs: [] files: [ .\BasicGenerator.class @@ -98,4 +99,4 @@ files: [ .\CountingGenerator$Double.class .\CountingGenerator$Float.class ... -*///:~ +*/ diff --git a/com/mindviewinc/util/Enums.java b/com/mindviewinc/util/Enums.java index 4fe11ef1..05c135a2 100644 --- a/com/mindviewinc/util/Enums.java +++ b/com/mindviewinc/util/Enums.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Enums.java +// com/mindviewinc/util/Enums.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; import java.util.*; @@ -11,4 +11,4 @@ public class Enums { public static T random(T[] values) { return values[rand.nextInt(values.length)]; } -} ///:~ +} diff --git a/com/mindviewinc/util/FiveTuple.java b/com/mindviewinc/util/FiveTuple.java index fac272b1..9badb091 100644 --- a/com/mindviewinc/util/FiveTuple.java +++ b/com/mindviewinc/util/FiveTuple.java @@ -1,9 +1,9 @@ -//: com/mindviewinc/util/FiveTuple.java +// com/mindviewinc/util/FiveTuple.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; -public class FiveTuple -extends FourTuple { +public class FiveTuple +extends FourTuple { public final E fifth; public FiveTuple(A a, B b, C c, D d, E e) { super(a, b, c, d); @@ -14,4 +14,4 @@ extends FourTuple { return "(" + first + ", " + second + ", " + third + ", " + fourth + ", " + fifth + ")"; } -} ///:~ +} diff --git a/com/mindviewinc/util/FourTuple.java b/com/mindviewinc/util/FourTuple.java index 1ab102fb..b9ef5181 100644 --- a/com/mindviewinc/util/FourTuple.java +++ b/com/mindviewinc/util/FourTuple.java @@ -1,8 +1,9 @@ -//: com/mindviewinc/util/FourTuple.java +// com/mindviewinc/util/FourTuple.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; -public class FourTuple extends ThreeTuple { +public class FourTuple + extends ThreeTuple { public final D fourth; public FourTuple(A a, B b, C c, D d) { super(a, b, c); @@ -13,4 +14,4 @@ public class FourTuple extends ThreeTuple { return "(" + first + ", " + second + ", " + third + ", " + fourth + ")"; } -} ///:~ +} diff --git a/com/mindviewinc/util/Generated.java b/com/mindviewinc/util/Generated.java index 2e343b7b..c4460bb1 100644 --- a/com/mindviewinc/util/Generated.java +++ b/com/mindviewinc/util/Generated.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Generated.java +// com/mindviewinc/util/Generated.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; @@ -15,4 +15,4 @@ public class Generated { (T[])java.lang.reflect.Array.newInstance(type, size); return new CollectionData<>(gen, size).toArray(a); } -} ///:~ +} diff --git a/com/mindviewinc/util/Generator.java b/com/mindviewinc/util/Generator.java index ba69f7d8..32dc0e75 100644 --- a/com/mindviewinc/util/Generator.java +++ b/com/mindviewinc/util/Generator.java @@ -1,5 +1,5 @@ -//: com/mindviewinc/util/Generator.java +// com/mindviewinc/util/Generator.java // ©2015 MindView LLC: see Copyright.txt // A generic interface. package com.mindviewinc.util; -public interface Generator { T next(); } ///:~ +public interface Generator { T next(); } diff --git a/com/mindviewinc/util/Hex.java b/com/mindviewinc/util/Hex.java index 302b5e55..02807829 100644 --- a/com/mindviewinc/util/Hex.java +++ b/com/mindviewinc/util/Hex.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Hex.java +// com/mindviewinc/util/Hex.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; import java.io.*; @@ -26,7 +26,8 @@ public class Hex { System.out.println( format(BinaryFile.read(new File(args[0])))); } -} /* Output: (First 6 Lines) +} +/* Output: (First 6 Lines) 00000: CA FE BA BE 00 00 00 34 00 53 0A 00 05 00 22 07 00010: 00 23 0A 00 02 00 22 08 00 24 07 00 25 0A 00 26 00020: 00 27 0A 00 28 00 29 0A 00 02 00 2A 08 00 2B 0A @@ -34,4 +35,4 @@ public class Hex { 00040: 31 08 00 32 0A 00 33 00 34 0A 00 15 00 35 0A 00 00050: 36 00 37 07 00 38 0A 00 12 00 39 0A 00 33 00 3A ... -*///:~ +*/ diff --git a/com/mindviewinc/util/MapData.java b/com/mindviewinc/util/MapData.java index 0f0d7dc1..d9709c5c 100644 --- a/com/mindviewinc/util/MapData.java +++ b/com/mindviewinc/util/MapData.java @@ -1,14 +1,14 @@ -//: com/mindviewinc/util/MapData.java +// com/mindviewinc/util/MapData.java // ©2015 MindView LLC: see Copyright.txt // A Map filled with data using a generator object. package com.mindviewinc.util; import java.util.*; -public class MapData extends LinkedHashMap { +public class MapData extends LinkedHashMap { // A single Pair Generator: - public MapData(Generator> gen, int quantity) { + public MapData(Generator> gen, int quantity) { for(int i = 0; i < quantity; i++) { - Pair p = gen.next(); + Pair p = gen.next(); put(p.key, p.value); } } @@ -38,24 +38,24 @@ public class MapData extends LinkedHashMap { } } // Generic convenience methods: - public static MapData - map(Generator> gen, int quantity) { + public static MapData + map(Generator> gen, int quantity) { return new MapData<>(gen, quantity); } - public static MapData + public static MapData map(Generator genK, Generator genV, int quantity) { return new MapData<>(genK, genV, quantity); } - public static MapData + public static MapData map(Generator genK, V value, int quantity) { return new MapData<>(genK, value, quantity); } - public static MapData + public static MapData map(Iterable genK, Generator genV) { return new MapData<>(genK, genV); } - public static MapData + public static MapData map(Iterable genK, V value) { return new MapData<>(genK, value); } -} ///:~ +} diff --git a/com/mindviewinc/util/New.java b/com/mindviewinc/util/New.java index 9b84a018..b934e289 100644 --- a/com/mindviewinc/util/New.java +++ b/com/mindviewinc/util/New.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/New.java +// com/mindviewinc/util/New.java // ©2015 MindView LLC: see Copyright.txt // Utilities to simplify generic container creation // by using type argument inference. @@ -6,7 +6,7 @@ package com.mindviewinc.util; import java.util.*; public class New { - public static Map map() { + public static Map map() { return new HashMap<>(); } public static List list() { @@ -29,4 +29,5 @@ public class New { Set ss = New.set(); Queue qs = New.queue(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/com/mindviewinc/util/Null.java b/com/mindviewinc/util/Null.java index 7a4aa60b..0f56f26e 100644 --- a/com/mindviewinc/util/Null.java +++ b/com/mindviewinc/util/Null.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Null.java +// com/mindviewinc/util/Null.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; -public interface Null {} ///:~ +public interface Null {} diff --git a/com/mindviewinc/util/OSExecute.java b/com/mindviewinc/util/OSExecute.java index 840d42a9..fedd52e0 100644 --- a/com/mindviewinc/util/OSExecute.java +++ b/com/mindviewinc/util/OSExecute.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/OSExecute.java +// com/mindviewinc/util/OSExecute.java // ©2015 MindView LLC: see Copyright.txt // Run an operating system command // and send the output to the console. @@ -36,4 +36,4 @@ public class OSExecute { throw new OSExecuteException("Errors executing " + command); } -} ///:~ +} diff --git a/com/mindviewinc/util/OSExecuteException.java b/com/mindviewinc/util/OSExecuteException.java index 1b210544..0d89c8a1 100644 --- a/com/mindviewinc/util/OSExecuteException.java +++ b/com/mindviewinc/util/OSExecuteException.java @@ -1,7 +1,7 @@ -//: com/mindviewinc/util/OSExecuteException.java +// com/mindviewinc/util/OSExecuteException.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; public class OSExecuteException extends RuntimeException { public OSExecuteException(String why) { super(why); } -} ///:~ +} diff --git a/com/mindviewinc/util/PPrint.java b/com/mindviewinc/util/PPrint.java index 258bf673..1ed5858b 100644 --- a/com/mindviewinc/util/PPrint.java +++ b/com/mindviewinc/util/PPrint.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/PPrint.java +// com/mindviewinc/util/PPrint.java // ©2015 MindView LLC: see Copyright.txt // Pretty-printer for collections package com.mindviewinc.util; @@ -24,4 +24,4 @@ public class PPrint { public static void pprint(Object[] c) { System.out.println(pformat(Arrays.asList(c))); } -} ///:~ +} diff --git a/com/mindviewinc/util/Pair.java b/com/mindviewinc/util/Pair.java index da5fe71f..3ec8e185 100644 --- a/com/mindviewinc/util/Pair.java +++ b/com/mindviewinc/util/Pair.java @@ -1,12 +1,12 @@ -//: com/mindviewinc/util/Pair.java +// com/mindviewinc/util/Pair.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; -public class Pair { +public class Pair { public final K key; public final V value; public Pair(K k, V v) { key = k; value = v; } -} ///:~ +} diff --git a/com/mindviewinc/util/Print.java b/com/mindviewinc/util/Print.java index 40125a66..fa582788 100644 --- a/com/mindviewinc/util/Print.java +++ b/com/mindviewinc/util/Print.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Print.java +// com/mindviewinc/util/Print.java // ©2015 MindView LLC: see Copyright.txt // Print methods that can be used without // qualifiers, using static imports: @@ -23,4 +23,4 @@ public class Print { printf(String format, Object... args) { return System.out.printf(format, args); } -} ///:~ +} diff --git a/com/mindviewinc/util/PrintArray.java b/com/mindviewinc/util/PrintArray.java index 421c796c..fae97356 100644 --- a/com/mindviewinc/util/PrintArray.java +++ b/com/mindviewinc/util/PrintArray.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/PrintArray.java +// com/mindviewinc/util/PrintArray.java // ©2015 MindView LLC: see Copyright.txt // Display an array of double package com.mindviewinc.util; @@ -12,4 +12,4 @@ public class PrintArray { } System.out.println(); } -} ///:~ +} diff --git a/com/mindviewinc/util/ProcessFiles.java b/com/mindviewinc/util/ProcessFiles.java index c70a66c2..5448f8eb 100644 --- a/com/mindviewinc/util/ProcessFiles.java +++ b/com/mindviewinc/util/ProcessFiles.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/ProcessFiles.java +// com/mindviewinc/util/ProcessFiles.java // ©2015 MindView LLC: see Copyright.txt // {ValidateByHand} package com.mindviewinc.util; @@ -46,4 +46,5 @@ public class ProcessFiles { new ProcessFiles(file -> System.out.println(file), "java").start(args); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/com/mindviewinc/util/RandomGenerator.java b/com/mindviewinc/util/RandomGenerator.java index 1f14949c..9b507a1d 100644 --- a/com/mindviewinc/util/RandomGenerator.java +++ b/com/mindviewinc/util/RandomGenerator.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/RandomGenerator.java +// com/mindviewinc/util/RandomGenerator.java // ©2015 MindView LLC: see Copyright.txt // Generators that produce random values. package com.mindviewinc.util; @@ -79,4 +79,4 @@ public class RandomGenerator { return ((double)trimmed) / 100; } } -} ///:~ +} diff --git a/com/mindviewinc/util/Range.java b/com/mindviewinc/util/Range.java index 3fca450f..744a258d 100644 --- a/com/mindviewinc/util/Range.java +++ b/com/mindviewinc/util/Range.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Range.java +// com/mindviewinc/util/Range.java // ©2015 MindView LLC: see Copyright.txt // Array creation methods that can be used without // qualifiers, using static imports: @@ -28,4 +28,4 @@ public class Range { result[i] = start + (i * step); return result; } -} ///:~ +} diff --git a/com/mindviewinc/util/Sets.java b/com/mindviewinc/util/Sets.java index aba94d8c..d81ece19 100644 --- a/com/mindviewinc/util/Sets.java +++ b/com/mindviewinc/util/Sets.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Sets.java +// com/mindviewinc/util/Sets.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; import java.util.*; @@ -26,4 +26,4 @@ public class Sets { public static Set complement(Set a, Set b) { return difference(union(a, b), intersection(a, b)); } -} ///:~ +} diff --git a/com/mindviewinc/util/Sleep.java b/com/mindviewinc/util/Sleep.java index 827d00cd..e36ac1a3 100644 --- a/com/mindviewinc/util/Sleep.java +++ b/com/mindviewinc/util/Sleep.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Sleep.java +// com/mindviewinc/util/Sleep.java // ©2015 MindView LLC: see Copyright.txt // Sleep for n seconds. package com.mindviewinc.util; @@ -12,4 +12,4 @@ public class Sleep { throw new RuntimeException(e); } } -} ///:~ +} diff --git a/com/mindviewinc/util/Stack.java b/com/mindviewinc/util/Stack.java index 03077b51..5a96cddd 100644 --- a/com/mindviewinc/util/Stack.java +++ b/com/mindviewinc/util/Stack.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/Stack.java +// com/mindviewinc/util/Stack.java // ©2015 MindView LLC: see Copyright.txt // Making a stack from a LinkedList. package com.mindviewinc.util; @@ -12,4 +12,4 @@ public class Stack { public boolean empty() { return storage.isEmpty(); } @Override public String toString() { return storage.toString(); } -} ///:~ +} diff --git a/com/mindviewinc/util/SwingConsole.java b/com/mindviewinc/util/SwingConsole.java index fea0eb78..442d79b9 100644 --- a/com/mindviewinc/util/SwingConsole.java +++ b/com/mindviewinc/util/SwingConsole.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/SwingConsole.java +// com/mindviewinc/util/SwingConsole.java // ©2015 MindView LLC: see Copyright.txt // Tool for running Swing demos from the // console, both applets and JFrames. @@ -15,4 +15,4 @@ public class SwingConsole { f.setVisible(true); }); } -} ///:~ +} diff --git a/com/mindviewinc/util/TaskItem.java b/com/mindviewinc/util/TaskItem.java index de2f9c36..d57389a4 100644 --- a/com/mindviewinc/util/TaskItem.java +++ b/com/mindviewinc/util/TaskItem.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/TaskItem.java +// com/mindviewinc/util/TaskItem.java // ©2015 MindView LLC: see Copyright.txt // A Future and the Callable that produced it. package com.mindviewinc.util; @@ -11,4 +11,4 @@ public class TaskItem> { this.future = future; this.task = task; } -} ///:~ +} diff --git a/com/mindviewinc/util/TaskManager.java b/com/mindviewinc/util/TaskManager.java index f59f8dd0..c039c5a7 100644 --- a/com/mindviewinc/util/TaskManager.java +++ b/com/mindviewinc/util/TaskManager.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/TaskManager.java +// com/mindviewinc/util/TaskManager.java // ©2015 MindView LLC: see Copyright.txt // Managing and executing a queue of tasks. package com.mindviewinc.util; @@ -43,4 +43,4 @@ extends ArrayList> { } return results; } -} ///:~ +} diff --git a/com/mindviewinc/util/TextFile.java b/com/mindviewinc/util/TextFile.java index 25a0212a..27a1846e 100644 --- a/com/mindviewinc/util/TextFile.java +++ b/com/mindviewinc/util/TextFile.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/TextFile.java +// com/mindviewinc/util/TextFile.java // ©2015 MindView LLC: see Copyright.txt // Static functions for reading and writing text files as // a single string, and treating a file as an ArrayList. @@ -70,10 +70,11 @@ public class TextFile extends ArrayList { // Display the capitalized words: System.out.println(words.headSet("a")); } -} /* Output: +} +/* Output: [0, ArrayList, Arrays, Break, BufferedReader, BufferedWriter, Clean, Display, File, FileReader, FileWriter, IOException, Normally, Output, PrintWriter, Read, Regular, RuntimeException, Simple, Static, String, StringBuilder, System, TextFile, Tools, TreeSet, W, Write] -*///:~ +*/ diff --git a/com/mindviewinc/util/ThreeTuple.java b/com/mindviewinc/util/ThreeTuple.java index c1f457fd..7978a570 100644 --- a/com/mindviewinc/util/ThreeTuple.java +++ b/com/mindviewinc/util/ThreeTuple.java @@ -1,8 +1,8 @@ -//: com/mindviewinc/util/ThreeTuple.java +// com/mindviewinc/util/ThreeTuple.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; -public class ThreeTuple extends TwoTuple { +public class ThreeTuple extends TwoTuple { public final C third; public ThreeTuple(A a, B b, C c) { super(a, b); @@ -12,4 +12,4 @@ public class ThreeTuple extends TwoTuple { public String toString() { return "(" + first + ", " + second + ", " + third +")"; } -} ///:~ +} diff --git a/com/mindviewinc/util/TimedAbort.java b/com/mindviewinc/util/TimedAbort.java index e97ecdf1..a25dc54b 100644 --- a/com/mindviewinc/util/TimedAbort.java +++ b/com/mindviewinc/util/TimedAbort.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/TimedAbort.java +// com/mindviewinc/util/TimedAbort.java // ©2015 MindView LLC: see Copyright.txt // Terminate a program after n seconds. package com.mindviewinc.util; @@ -14,4 +14,4 @@ public class TimedAbort { } }, n * 1000); } -} ///:~ +} diff --git a/com/mindviewinc/util/Tuple.java b/com/mindviewinc/util/Tuple.java index c2538683..cd8af884 100644 --- a/com/mindviewinc/util/Tuple.java +++ b/com/mindviewinc/util/Tuple.java @@ -1,22 +1,22 @@ -//: com/mindviewinc/util/Tuple.java +// com/mindviewinc/util/Tuple.java // ©2015 MindView LLC: see Copyright.txt // Tuple library using type argument inference. package com.mindviewinc.util; public class Tuple { - public static TwoTuple tuple(A a, B b) { + public static TwoTuple tuple(A a, B b) { return new TwoTuple<>(a, b); } - public static ThreeTuple + public static ThreeTuple tuple(A a, B b, C c) { return new ThreeTuple<>(a, b, c); } - public static FourTuple + public static FourTuple tuple(A a, B b, C c, D d) { return new FourTuple<>(a, b, c, d); } - public static - FiveTuple tuple(A a, B b, C c, D d, E e) { + public static + FiveTuple tuple(A a, B b, C c, D d, E e) { return new FiveTuple<>(a, b, c, d, e); } -} ///:~ +} diff --git a/com/mindviewinc/util/TwoTuple.java b/com/mindviewinc/util/TwoTuple.java index 74a78236..16c8a7a9 100644 --- a/com/mindviewinc/util/TwoTuple.java +++ b/com/mindviewinc/util/TwoTuple.java @@ -1,8 +1,8 @@ -//: com/mindviewinc/util/TwoTuple.java +// com/mindviewinc/util/TwoTuple.java // ©2015 MindView LLC: see Copyright.txt package com.mindviewinc.util; -public class TwoTuple { +public class TwoTuple { public final A first; public final B second; public TwoTuple(A a, B b) { first = a; second = b; } @@ -10,4 +10,4 @@ public class TwoTuple { public String toString() { return "(" + first + ", " + second + ")"; } -} ///:~ +} diff --git a/com/mindviewinc/util/TypeCounter.java b/com/mindviewinc/util/TypeCounter.java index 8198719d..060c75b5 100644 --- a/com/mindviewinc/util/TypeCounter.java +++ b/com/mindviewinc/util/TypeCounter.java @@ -1,4 +1,4 @@ -//: com/mindviewinc/util/TypeCounter.java +// com/mindviewinc/util/TypeCounter.java // ©2015 MindView LLC: see Copyright.txt // Counts instances of a type family. package com.mindviewinc.util; @@ -38,4 +38,4 @@ public class TypeCounter extends HashMap,Integer>{ result.append("}"); return result.toString(); } -} ///:~ +} diff --git a/concurrency/ActiveObjectDemo.java b/concurrency/ActiveObjectDemo.java index dbeea0f8..a99d2510 100644 --- a/concurrency/ActiveObjectDemo.java +++ b/concurrency/ActiveObjectDemo.java @@ -1,4 +1,4 @@ -//: concurrency/ActiveObjectDemo.java +// concurrency/ActiveObjectDemo.java // ©2015 MindView LLC: see Copyright.txt // Can only pass constants, immutables, "disconnected // objects," or other active objects as arguments @@ -62,7 +62,8 @@ public class ActiveObjectDemo { } d1.shutdown(); } -} /* Output: +} +/* Output: starting 0.0 + 0.0 All asynch calls made 0.0 @@ -84,4 +85,4 @@ starting 3 + 3 6 starting 4 + 4 8 -*///:~ +*/ diff --git a/concurrency/AtomicEvenGenerator.java b/concurrency/AtomicEvenGenerator.java index d3756df2..9d4f5e02 100644 --- a/concurrency/AtomicEvenGenerator.java +++ b/concurrency/AtomicEvenGenerator.java @@ -1,4 +1,4 @@ -//: concurrency/AtomicEvenGenerator.java +// concurrency/AtomicEvenGenerator.java // ©2015 MindView LLC: see Copyright.txt // Atomic classes are occasionally useful in regular code. // {TimeOutDuringTesting} @@ -14,4 +14,5 @@ public class AtomicEvenGenerator extends IntGenerator { public static void main(String[] args) { EvenChecker.test(new AtomicEvenGenerator()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/concurrency/AtomicIntegerTest.java b/concurrency/AtomicIntegerTest.java index 121f83f2..9fcb807d 100644 --- a/concurrency/AtomicIntegerTest.java +++ b/concurrency/AtomicIntegerTest.java @@ -1,4 +1,4 @@ -//: concurrency/AtomicIntegerTest.java +// concurrency/AtomicIntegerTest.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.concurrent.atomic.*; @@ -28,6 +28,7 @@ public class AtomicIntegerTest implements Runnable { } } } -} /* Output: +} +/* Output: TimedAbort 5 -*///:~ +*/ diff --git a/concurrency/Atomicity.java b/concurrency/Atomicity.java index e8ebf101..27f044e7 100644 --- a/concurrency/Atomicity.java +++ b/concurrency/Atomicity.java @@ -1,4 +1,4 @@ -//: concurrency/Atomicity.java +// concurrency/Atomicity.java // ©2015 MindView LLC: see Copyright.txt // {Exec: javap -c Atomicity} @@ -6,7 +6,8 @@ public class Atomicity { int i; void f1() { i++; } void f2() { i += 3; } -} /* Output: +} +/* Output: Compiled from "Atomicity.java" public class Atomicity { int i; @@ -35,4 +36,4 @@ java/lang/Object."":()V 7: putfield #2 // Field i:I 10: return } -*///:~ +*/ diff --git a/concurrency/AtomicityTest.java b/concurrency/AtomicityTest.java index 47e473c1..28d680f4 100644 --- a/concurrency/AtomicityTest.java +++ b/concurrency/AtomicityTest.java @@ -1,4 +1,4 @@ -//: concurrency/AtomicityTest.java +// concurrency/AtomicityTest.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; @@ -23,6 +23,7 @@ public class AtomicityTest implements Runnable { } } } -} /* Output: +} +/* Output: 1 -*///:~ +*/ diff --git a/concurrency/AttemptLocking.java b/concurrency/AttemptLocking.java index a00e6b9c..eaf5b320 100644 --- a/concurrency/AttemptLocking.java +++ b/concurrency/AttemptLocking.java @@ -1,4 +1,4 @@ -//: concurrency/AttemptLocking.java +// concurrency/AttemptLocking.java // ©2015 MindView LLC: see Copyright.txt // Locks in the concurrent library allow you // to give up on trying to acquire a lock. @@ -48,10 +48,11 @@ public class AttemptLocking { al.untimed(); // False -- lock grabbed by task al.timed(); // False -- lock grabbed by task } -} /* Output: +} +/* Output: tryLock(): true tryLock(2, TimeUnit.SECONDS): true tryLock(): true tryLock(2, TimeUnit.SECONDS): true acquired -*///:~ +*/ diff --git a/concurrency/BankTellerSimulation.java b/concurrency/BankTellerSimulation.java index a143365f..cf6125ab 100644 --- a/concurrency/BankTellerSimulation.java +++ b/concurrency/BankTellerSimulation.java @@ -1,4 +1,4 @@ -//: concurrency/BankTellerSimulation.java +// concurrency/BankTellerSimulation.java // ©2015 MindView LLC: see Copyright.txt // Using queues and multithreading. // {Args: 5} @@ -189,7 +189,8 @@ public class BankTellerSimulation { } exec.shutdownNow(); } -} /* Output: +} +/* Output: [200][207] { T1 T0 } [861][258][140][322] { T1 T0 } [575][342][804][826][896] { T1 T0 } @@ -204,4 +205,4 @@ Teller 0 terminating CustomerGenerator terminating TellerManager terminating Teller 1 terminating -*///:~ +*/ diff --git a/concurrency/BasicThreads.java b/concurrency/BasicThreads.java index c4e1a0f2..b749f4d9 100644 --- a/concurrency/BasicThreads.java +++ b/concurrency/BasicThreads.java @@ -1,4 +1,4 @@ -//: concurrency/BasicThreads.java +// concurrency/BasicThreads.java // ©2015 MindView LLC: see Copyright.txt // The most basic use of the Thread class. @@ -8,8 +8,9 @@ public class BasicThreads { t.start(); System.out.println("Waiting for LiftOff"); } -} /* Output: +} +/* Output: Waiting for LiftOff #0(9), #0(8), #0(7), #0(6), #0(5), #0(4), #0(3), #0(2), #0(1), #0(Liftoff!), -*///:~ +*/ diff --git a/concurrency/CachedThreadPool.java b/concurrency/CachedThreadPool.java index 189057e2..29d553ee 100644 --- a/concurrency/CachedThreadPool.java +++ b/concurrency/CachedThreadPool.java @@ -1,4 +1,4 @@ -//: concurrency/CachedThreadPool.java +// concurrency/CachedThreadPool.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; @@ -9,7 +9,8 @@ public class CachedThreadPool { exec.execute(new LiftOff()); exec.shutdown(); } -} /* Output: +} +/* Output: #0(9), #4(9), #3(9), #1(9), #2(9), #1(8), #3(8), #4(8), #0(8), #4(7), #3(7), #1(7), #2(8), #3(6), #4(6), #0(7), #4(5), #3(5), #1(6), #2(7), #1(5), #3(4), #4(4), #0(6), @@ -17,4 +18,4 @@ public class CachedThreadPool { #4(1), #0(3), #1(2), #2(5), #3(2), #2(4), #1(1), #0(2), #4(Liftoff!), #0(1), #1(Liftoff!), #2(3), #3(1), #2(2), #0(Liftoff!), #2(1), #3(Liftoff!), #2(Liftoff!), -*///:~ +*/ diff --git a/concurrency/CallableDemo.java b/concurrency/CallableDemo.java index 7a864c3c..9e6a652c 100644 --- a/concurrency/CallableDemo.java +++ b/concurrency/CallableDemo.java @@ -1,4 +1,4 @@ -//: concurrency/CallableDemo.java +// concurrency/CallableDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.*; @@ -33,7 +33,8 @@ public class CallableDemo { exec.shutdown(); } } -} /* Output: +} +/* Output: result of TaskWithResult 0 result of TaskWithResult 1 result of TaskWithResult 2 @@ -44,4 +45,4 @@ result of TaskWithResult 6 result of TaskWithResult 7 result of TaskWithResult 8 result of TaskWithResult 9 -*///:~ +*/ diff --git a/concurrency/CaptureUncaughtException.java b/concurrency/CaptureUncaughtException.java index d33a2839..b6f46224 100644 --- a/concurrency/CaptureUncaughtException.java +++ b/concurrency/CaptureUncaughtException.java @@ -1,4 +1,4 @@ -//: concurrency/CaptureUncaughtException.java +// concurrency/CaptureUncaughtException.java // ©2015 MindView LLC: see Copyright.txt // {TimeOutDuringTesting} import java.util.concurrent.*; @@ -42,11 +42,12 @@ public class CaptureUncaughtException { new HandlerThreadFactory()); exec.execute(new ExceptionThread2()); } -} /* Output: +} +/* Output: HandlerThreadFactory@de6ced creating new Thread created Thread[Thread-0,5,main] eh = MyUncaughtExceptionHandler@1fb8ee3 run() by Thread[Thread-0,5,main] eh = MyUncaughtExceptionHandler@1fb8ee3 caught java.lang.RuntimeException -*///:~ +*/ diff --git a/concurrency/CarBuilder.java b/concurrency/CarBuilder.java index eae3dd55..a2a846f6 100644 --- a/concurrency/CarBuilder.java +++ b/concurrency/CarBuilder.java @@ -1,4 +1,4 @@ -//: concurrency/CarBuilder.java +// concurrency/CarBuilder.java // ©2015 MindView LLC: see Copyright.txt // A complex example of tasks working together. import java.util.concurrent.*; @@ -209,7 +209,8 @@ public class CarBuilder { TimeUnit.SECONDS.sleep(7); exec.shutdownNow(); } -} /* Output: +} +/* Output: ChassisBuilder created Car 0 [ engine: false driveTrain: false wheels: false ] WheelRobot installing Wheels @@ -288,4 +289,4 @@ WheelRobot off ChassisBuilder off EngineRobot off Reporter off -*///:~ +*/ diff --git a/concurrency/Chopstick.java b/concurrency/Chopstick.java index 8d392892..7a1778e4 100644 --- a/concurrency/Chopstick.java +++ b/concurrency/Chopstick.java @@ -1,4 +1,4 @@ -//: concurrency/Chopstick.java +// concurrency/Chopstick.java // ©2015 MindView LLC: see Copyright.txt // Chopsticks for dining philosophers. @@ -14,4 +14,4 @@ public class Chopstick { taken = false; notifyAll(); } -} ///:~ +} diff --git a/concurrency/CloseResource.java b/concurrency/CloseResource.java index 3409c85f..3fff6032 100644 --- a/concurrency/CloseResource.java +++ b/concurrency/CloseResource.java @@ -1,4 +1,4 @@ -//: concurrency/CloseResource.java +// concurrency/CloseResource.java // ©2015 MindView LLC: see Copyright.txt // Interrupting a blocked task by // closing the underlying resource. @@ -27,7 +27,8 @@ public class CloseResource { print("Closing " + System.in.getClass().getName()); System.in.close(); // Releases blocked thread } -} /* Output: +} +/* Output: Waiting for read(): Waiting for read(): Shutting down all threads @@ -36,4 +37,4 @@ Interrupted from blocked I/O Exiting IOBlocked.run() Closing java.io.BufferedInputStream Exiting IOBlocked.run() -*///:~ +*/ diff --git a/concurrency/CountDownLatchDemo.java b/concurrency/CountDownLatchDemo.java index cf130e32..61f47eef 100644 --- a/concurrency/CountDownLatchDemo.java +++ b/concurrency/CountDownLatchDemo.java @@ -1,4 +1,4 @@ -//: concurrency/CountDownLatchDemo.java +// concurrency/CountDownLatchDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.*; @@ -68,7 +68,8 @@ public class CountDownLatchDemo { print("Launched all tasks"); exec.shutdown(); // Quit when all tasks complete } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Launched all tasks 56 completed 99 completed @@ -90,4 +91,4 @@ Latch barrier passed for WaitingTask 4 Latch barrier passed for WaitingTask 3 Latch barrier passed for WaitingTask 1 Latch barrier passed for WaitingTask 7 -*///:~ +*/ diff --git a/concurrency/CriticalSection.java b/concurrency/CriticalSection.java index da73759e..d03297d4 100644 --- a/concurrency/CriticalSection.java +++ b/concurrency/CriticalSection.java @@ -1,4 +1,4 @@ -//: concurrency/CriticalSection.java +// concurrency/CriticalSection.java // ©2015 MindView LLC: see Copyright.txt // {TimeOutDuringTesting} // (Behavior may have changed in Java 8). @@ -142,7 +142,8 @@ public class CriticalSection { pman2 = new PairManager2(); testApproaches(pman1, pman2); } -} /* Output: +} +/* Output: pm1: Pair: x: 15, y: 15 checkCounter = 272565 pm2: Pair: x: 16, y: 16 checkCounter = 3956974 -*///:~ +*/ diff --git a/concurrency/DaemonFromFactory.java b/concurrency/DaemonFromFactory.java index 28f3d5ed..fc8aff9c 100644 --- a/concurrency/DaemonFromFactory.java +++ b/concurrency/DaemonFromFactory.java @@ -1,4 +1,4 @@ -//: concurrency/DaemonFromFactory.java +// concurrency/DaemonFromFactory.java // ©2015 MindView LLC: see Copyright.txt // Using a Thread Factory to create daemons. import java.util.concurrent.*; @@ -25,7 +25,8 @@ public class DaemonFromFactory implements Runnable { print("All daemons started"); TimeUnit.MILLISECONDS.sleep(500); // Run for a while } -} /* Output: (First 10 Lines) +} +/* Output: (First 10 Lines) All daemons started Thread[Thread-7,5,main] DaemonFromFactory@e6b01c Thread[Thread-5,5,main] DaemonFromFactory@58daee @@ -37,4 +38,4 @@ Thread[Thread-0,5,main] DaemonFromFactory@1e19df Thread[Thread-3,5,main] DaemonFromFactory@963672 Thread[Thread-6,5,main] DaemonFromFactory@2f2043 ... -*///:~ +*/ diff --git a/concurrency/Daemons.java b/concurrency/Daemons.java index 10c93388..bd1336a2 100644 --- a/concurrency/Daemons.java +++ b/concurrency/Daemons.java @@ -1,4 +1,4 @@ -//: concurrency/Daemons.java +// concurrency/Daemons.java // ©2015 MindView LLC: see Copyright.txt // Daemon threads spawn other daemon threads. import java.util.concurrent.*; @@ -39,7 +39,8 @@ public class Daemons { // finish their startup processes: TimeUnit.SECONDS.sleep(1); } -} /* Output: +} +/* Output: d.isDaemon() = true, DaemonSpawn 0 started, DaemonSpawn 1 started, DaemonSpawn 2 started, DaemonSpawn 3 started, DaemonSpawn 4 started, DaemonSpawn 5 started, DaemonSpawn 6 @@ -50,4 +51,4 @@ t[3].isDaemon() = true, t[4].isDaemon() = true, t[5].isDaemon() = true, t[6].isDaemon() = true, t[7].isDaemon() = true, t[8].isDaemon() = true, t[9].isDaemon() = true, -*///:~ +*/ diff --git a/concurrency/DaemonsDoRunFinally.java b/concurrency/DaemonsDoRunFinally.java index 4ee6e64c..c1042db8 100644 --- a/concurrency/DaemonsDoRunFinally.java +++ b/concurrency/DaemonsDoRunFinally.java @@ -1,4 +1,4 @@ -//: concurrency/DaemonsDoRunFinally.java +// concurrency/DaemonsDoRunFinally.java // ©2015 MindView LLC: see Copyright.txt // Daemon threads now run the finally clause import java.util.concurrent.*; @@ -25,7 +25,8 @@ public class DaemonsDoRunFinally { t.start(); TimeUnit.SECONDS.sleep(2); } -} /* Output: +} +/* Output: Starting ADaemon ADaemon finally clause -*///:~ +*/ diff --git a/concurrency/DeadlockingDiningPhilosophers.java b/concurrency/DeadlockingDiningPhilosophers.java index c30774cc..414351b8 100644 --- a/concurrency/DeadlockingDiningPhilosophers.java +++ b/concurrency/DeadlockingDiningPhilosophers.java @@ -1,4 +1,4 @@ -//: concurrency/DeadlockingDiningPhilosophers.java +// concurrency/DeadlockingDiningPhilosophers.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates how deadlock can be hidden in a program. // {Args: 0 5 timeout} @@ -27,7 +27,8 @@ public class DeadlockingDiningPhilosophers { } exec.shutdownNow(); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Philosopher 1 thinking Philosopher 1 grabbing right Philosopher 1 grabbing left @@ -49,4 +50,4 @@ Philosopher 4 exiting via interrupt Philosopher 1 exiting via interrupt Philosopher 0 exiting via interrupt Philosopher 2 exiting via interrupt -*///:~ +*/ diff --git a/concurrency/DelayQueueDemo.java b/concurrency/DelayQueueDemo.java index cc8e6822..a8c37585 100644 --- a/concurrency/DelayQueueDemo.java +++ b/concurrency/DelayQueueDemo.java @@ -1,4 +1,4 @@ -//: concurrency/DelayQueueDemo.java +// concurrency/DelayQueueDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.*; @@ -88,7 +88,8 @@ public class DelayQueueDemo { queue.add(new DelayedTask.EndSentinel(5000, exec)); exec.execute(new DelayedTaskConsumer(queue)); } -} /* Output: +} +/* Output: [128 ] Task 11 [200 ] Task 7 [429 ] Task 5 [520 ] Task 18 [555 ] Task 1 [961 ] Task 4 [998 ] Task 16 [1207] Task 9 [1693] Task 2 [1809] Task 14 [1861] Task 3 [2278] Task 15 @@ -100,4 +101,4 @@ public class DelayQueueDemo { (19:4258) (20:5000) [5000] Task 20 Calling shutdownNow() Finished DelayedTaskConsumer -*///:~ +*/ diff --git a/concurrency/EvenChecker.java b/concurrency/EvenChecker.java index 93483d98..bcbdd34e 100644 --- a/concurrency/EvenChecker.java +++ b/concurrency/EvenChecker.java @@ -1,4 +1,4 @@ -//: concurrency/EvenChecker.java +// concurrency/EvenChecker.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; @@ -31,4 +31,4 @@ public class EvenChecker implements Runnable { public static void test(IntGenerator gp) { test(gp, 10); } -} ///:~ +} diff --git a/concurrency/EvenGenerator.java b/concurrency/EvenGenerator.java index d161bcdf..20bdc4e0 100644 --- a/concurrency/EvenGenerator.java +++ b/concurrency/EvenGenerator.java @@ -1,4 +1,4 @@ -//: concurrency/EvenGenerator.java +// concurrency/EvenGenerator.java // ©2015 MindView LLC: see Copyright.txt // When threads collide. @@ -13,11 +13,12 @@ public class EvenGenerator extends IntGenerator { public static void main(String[] args) { EvenChecker.test(new EvenGenerator()); } -} /* Output: +} +/* Output: Press Control-C to exit 1649 not even! 1657 not even! 1655 not even! 1653 not even! 1651 not even! -*///:~ +*/ diff --git a/concurrency/ExceptionThread.java b/concurrency/ExceptionThread.java index ea897ce6..83378a50 100644 --- a/concurrency/ExceptionThread.java +++ b/concurrency/ExceptionThread.java @@ -1,4 +1,4 @@ -//: concurrency/ExceptionThread.java +// concurrency/ExceptionThread.java // ©2015 MindView LLC: see Copyright.txt // {ValidateByHand} // {ThrowsException} @@ -13,4 +13,4 @@ public class ExceptionThread implements Runnable { ExecutorService exec = Executors.newCachedThreadPool(); exec.execute(new ExceptionThread()); } -} ///:~ +} diff --git a/concurrency/ExchangerDemo.java b/concurrency/ExchangerDemo.java index fe1c4687..87d0733a 100644 --- a/concurrency/ExchangerDemo.java +++ b/concurrency/ExchangerDemo.java @@ -1,4 +1,4 @@ -//: concurrency/ExchangerDemo.java +// concurrency/ExchangerDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import com.mindviewinc.util.*; @@ -74,6 +74,7 @@ public class ExchangerDemo { TimeUnit.SECONDS.sleep(delay); exec.shutdownNow(); } -} /* Output: +} +/* Output: Final value: Fat id: 18859 -*///:~ +*/ diff --git a/concurrency/ExplicitCriticalSection.java b/concurrency/ExplicitCriticalSection.java index 8d0bdecd..d8e80634 100644 --- a/concurrency/ExplicitCriticalSection.java +++ b/concurrency/ExplicitCriticalSection.java @@ -1,4 +1,4 @@ -//: concurrency/ExplicitCriticalSection.java +// concurrency/ExplicitCriticalSection.java // ©2015 MindView LLC: see Copyright.txt // {ThrowsException} on a multiprocessor machine // Using explicit Lock objects to create @@ -48,7 +48,8 @@ public class ExplicitCriticalSection { pman2 = new ExplicitPairManager2(); CriticalSection.testApproaches(pman1, pman2); } -} /* Output: +} +/* Output: pm1: Pair: x: 10, y: 10 checkCounter = 68453 pm2: Pair: x: 11, y: 11 checkCounter = 663407 ___[ Error Output ]___ @@ -81,4 +82,4 @@ java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/concurrency/FastSimulation.java b/concurrency/FastSimulation.java index fd69504b..b0acde98 100644 --- a/concurrency/FastSimulation.java +++ b/concurrency/FastSimulation.java @@ -1,4 +1,4 @@ -//: concurrency/FastSimulation.java +// concurrency/FastSimulation.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.concurrent.atomic.*; @@ -49,7 +49,8 @@ public class FastSimulation { TimeUnit.SECONDS.sleep(5); exec.shutdownNow(); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Old value changed from 542 Old value changed from 447 Old value changed from 446 @@ -71,4 +72,4 @@ Old value changed from 467 Old value changed from 368 Old value changed from 404 Old value changed from 428 -*///:~ +*/ diff --git a/concurrency/Fat.java b/concurrency/Fat.java index b8951cff..d056813e 100644 --- a/concurrency/Fat.java +++ b/concurrency/Fat.java @@ -1,4 +1,4 @@ -//: concurrency/Fat.java +// concurrency/Fat.java // ©2015 MindView LLC: see Copyright.txt // Objects that are expensive to create. @@ -15,4 +15,4 @@ public class Fat { public void operation() { System.out.println(this); } @Override public String toString() { return "Fat id: " + id; } -} ///:~ +} diff --git a/concurrency/FixedDiningPhilosophers.java b/concurrency/FixedDiningPhilosophers.java index faeea09d..990a21b0 100644 --- a/concurrency/FixedDiningPhilosophers.java +++ b/concurrency/FixedDiningPhilosophers.java @@ -1,4 +1,4 @@ -//: concurrency/FixedDiningPhilosophers.java +// concurrency/FixedDiningPhilosophers.java // ©2015 MindView LLC: see Copyright.txt // Dining philosophers without deadlock. // {Args: 5 5 timeout} @@ -31,7 +31,8 @@ public class FixedDiningPhilosophers { } exec.shutdownNow(); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Philosopher 4 thinking Philosopher 3 thinking Philosopher 0 thinking @@ -53,4 +54,4 @@ Philosopher 4 grabbing left Philosopher 2 exiting via interrupt Philosopher 4 eating Philosopher 4 exiting via interrupt -*///:~ +*/ diff --git a/concurrency/FixedThreadPool.java b/concurrency/FixedThreadPool.java index 50bc169b..93816eb6 100644 --- a/concurrency/FixedThreadPool.java +++ b/concurrency/FixedThreadPool.java @@ -1,4 +1,4 @@ -//: concurrency/FixedThreadPool.java +// concurrency/FixedThreadPool.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; @@ -10,7 +10,8 @@ public class FixedThreadPool { exec.execute(new LiftOff()); exec.shutdown(); } -} /* Output: +} +/* Output: #3(9), #2(9), #3(8), #2(8), #1(9), #4(9), #0(9), #2(7), #3(7), #1(8), #0(8), #4(8), #3(6), #2(6), #0(7), #1(7), #0(6), #2(5), #4(7), #3(5), #0(5), #1(6), #0(4), #4(6), @@ -18,4 +19,4 @@ public class FixedThreadPool { #0(2), #4(4), #1(4), #0(1), #2(1), #3(2), #0(Liftoff!), #1(3), #4(3), #1(2), #3(1), #2(Liftoff!), #3(Liftoff!), #1(1), #4(2), #1(Liftoff!), #4(1), #4(Liftoff!), -*///:~ +*/ diff --git a/concurrency/GreenhouseScheduler.java b/concurrency/GreenhouseScheduler.java index 78d33ca8..299f4eb9 100644 --- a/concurrency/GreenhouseScheduler.java +++ b/concurrency/GreenhouseScheduler.java @@ -1,4 +1,4 @@ -//: concurrency/GreenhouseScheduler.java +// concurrency/GreenhouseScheduler.java // ©2015 MindView LLC: see Copyright.txt // Rewriting innerclasses/GreenhouseController.java // to use a ScheduledThreadPoolExecutor. @@ -163,7 +163,8 @@ public class GreenhouseScheduler { gh.repeat(gh.new ThermostatDay(), 0, 1400); gh.repeat(gh.new CollectData(), 500, 500); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Bing! Thermostat to night setting Turning on lights @@ -194,4 +195,4 @@ Mon Jun 15 19:30:00 PDT 2015 temperature: 70.1 humidity: 50.25 Mon Jun 15 20:00:00 PDT 2015 temperature: 68.9 humidity: 51.00 -*///:~ +*/ diff --git a/concurrency/HorseRace.java b/concurrency/HorseRace.java index 2009febb..2f7ac549 100644 --- a/concurrency/HorseRace.java +++ b/concurrency/HorseRace.java @@ -1,4 +1,4 @@ -//: concurrency/HorseRace.java +// concurrency/HorseRace.java // ©2015 MindView LLC: see Copyright.txt // Using CyclicBarriers. import java.util.concurrent.*; @@ -85,7 +85,8 @@ public class HorseRace { } new HorseRace(nHorses, pause); } -} /* Output: (First and last 18 Lines) +} +/* Output: (First and last 18 Lines) =========================================================== ================ *0 @@ -140,4 +141,4 @@ ________...________...________...________...________ *************5 ********************************************************6 Horse 3 won! -*///:~ +*/ diff --git a/concurrency/IntGenerator.java b/concurrency/IntGenerator.java index 2b4373fe..4cb661a4 100644 --- a/concurrency/IntGenerator.java +++ b/concurrency/IntGenerator.java @@ -1,4 +1,4 @@ -//: concurrency/IntGenerator.java +// concurrency/IntGenerator.java // ©2015 MindView LLC: see Copyright.txt public abstract class IntGenerator { @@ -7,4 +7,4 @@ public abstract class IntGenerator { // Allow this to be canceled: public void cancel() { canceled = true; } public boolean isCanceled() { return canceled; } -} ///:~ +} diff --git a/concurrency/Interrupting.java b/concurrency/Interrupting.java index bbab185e..80a2f20f 100644 --- a/concurrency/Interrupting.java +++ b/concurrency/Interrupting.java @@ -1,4 +1,4 @@ -//: concurrency/Interrupting.java +// concurrency/Interrupting.java // ©2015 MindView LLC: see Copyright.txt // Interrupting a blocked thread. import java.util.concurrent.*; @@ -75,7 +75,8 @@ public class Interrupting { print("Aborting with System.exit(0)"); System.exit(0); // ... since last 2 interrupts failed } -} /* Output: +} +/* Output: Interrupting SleepBlocked InterruptedException Exiting SleepBlocked.run() @@ -87,4 +88,4 @@ Trying to call f() Interrupting SynchronizedBlocked Interrupt sent to SynchronizedBlocked Aborting with System.exit(0) -*///:~ +*/ diff --git a/concurrency/Interrupting2.java b/concurrency/Interrupting2.java index 24d206b3..66db5f04 100644 --- a/concurrency/Interrupting2.java +++ b/concurrency/Interrupting2.java @@ -1,4 +1,4 @@ -//: concurrency/Interrupting2.java +// concurrency/Interrupting2.java // ©2015 MindView LLC: see Copyright.txt // Interrupting a task blocked with a ReentrantLock. import java.util.concurrent.*; @@ -41,9 +41,10 @@ public class Interrupting2 { System.out.println("Issuing t.interrupt()"); t.interrupt(); } -} /* Output: +} +/* Output: Waiting for f() in BlockedMutex Issuing t.interrupt() Interrupted from lock acquisition in f() Broken out of blocked call -*///:~ +*/ diff --git a/concurrency/InterruptingIdiom.java b/concurrency/InterruptingIdiom.java index dd34000a..679b756a 100644 --- a/concurrency/InterruptingIdiom.java +++ b/concurrency/InterruptingIdiom.java @@ -1,4 +1,4 @@ -//: concurrency/InterruptingIdiom.java +// concurrency/InterruptingIdiom.java // ©2015 MindView LLC: see Copyright.txt // General idiom for interrupting a task. // {Args: 1100} @@ -63,7 +63,8 @@ public class InterruptingIdiom { TimeUnit.MILLISECONDS.sleep(new Integer(args[0])); t.interrupt(); } -} /* Output: +} +/* Output: NeedsCleanup 1 Sleeping NeedsCleanup 2 @@ -72,4 +73,4 @@ Finished time-consuming operation Cleaning up 2 Cleaning up 1 Exiting via while() test -*///:~ +*/ diff --git a/concurrency/Joining.java b/concurrency/Joining.java index 55525b0d..a3185910 100644 --- a/concurrency/Joining.java +++ b/concurrency/Joining.java @@ -1,4 +1,4 @@ -//: concurrency/Joining.java +// concurrency/Joining.java // ©2015 MindView LLC: see Copyright.txt // Understanding join(). import static com.mindviewinc.util.Print.*; @@ -51,9 +51,10 @@ public class Joining { doc = new Joiner("Doc", grumpy); grumpy.interrupt(); } -} /* Output: +} +/* Output: Grumpy was interrupted. isInterrupted(): false Doc join completed Sleepy has awakened Dopey join completed -*///:~ +*/ diff --git a/concurrency/LiftOff.java b/concurrency/LiftOff.java index e75b38a8..990e6c9e 100644 --- a/concurrency/LiftOff.java +++ b/concurrency/LiftOff.java @@ -1,4 +1,4 @@ -//: concurrency/LiftOff.java +// concurrency/LiftOff.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of the Runnable interface. @@ -21,4 +21,4 @@ public class LiftOff implements Runnable { Thread.yield(); } } -} ///:~ +} diff --git a/concurrency/ListComparisons.java b/concurrency/ListComparisons.java index 90a4567f..47f89766 100644 --- a/concurrency/ListComparisons.java +++ b/concurrency/ListComparisons.java @@ -1,4 +1,4 @@ -//: concurrency/ListComparisons.java +// concurrency/ListComparisons.java // ©2015 MindView LLC: see Copyright.txt // {Args: 1 10 10} (Fast verification check during build) // Rough comparison of thread-safe List performance. @@ -72,7 +72,8 @@ public class ListComparisons { new CopyOnWriteArrayListTest(5, 5); Tester.exec.shutdown(); } -} /* Output: +} +/* Output: Type Read time Write time Synched ArrayList 10r 0w 700989 0 Synched ArrayList 9r 1w 2531313 60622 @@ -84,4 +85,4 @@ CopyOnWriteArrayList 9r 1w 161945 123521 readTime + writeTime = 285466 CopyOnWriteArrayList 5r 5w 549580 4230146 readTime + writeTime = 4779726 -*///:~ +*/ diff --git a/concurrency/MainThread.java b/concurrency/MainThread.java index 480d990d..0b527b65 100644 --- a/concurrency/MainThread.java +++ b/concurrency/MainThread.java @@ -1,4 +1,4 @@ -//: concurrency/MainThread.java +// concurrency/MainThread.java // ©2015 MindView LLC: see Copyright.txt public class MainThread { @@ -6,7 +6,8 @@ public class MainThread { LiftOff launch = new LiftOff(); launch.run(); } -} /* Output: +} +/* Output: #0(9), #0(8), #0(7), #0(6), #0(5), #0(4), #0(3), #0(2), #0(1), #0(Liftoff!), -*///:~ +*/ diff --git a/concurrency/MapComparisons.java b/concurrency/MapComparisons.java index af2493c5..c625b8c3 100644 --- a/concurrency/MapComparisons.java +++ b/concurrency/MapComparisons.java @@ -1,4 +1,4 @@ -//: concurrency/MapComparisons.java +// concurrency/MapComparisons.java // ©2015 MindView LLC: see Copyright.txt // {Args: 1 10 10} (Fast verification check during build) // Rough comparison of thread-safe Map performance. @@ -78,7 +78,8 @@ public class MapComparisons { new ConcurrentHashMapTest(5, 5); Tester.exec.shutdown(); } -} /* Output: +} +/* Output: Type Read time Write time Synched HashMap 10r 0w 2825885 0 Synched HashMap 9r 1w 3463976 74283 @@ -90,4 +91,4 @@ ConcurrentHashMap 9r 1w 545597 78268 readTime + writeTime = 623865 ConcurrentHashMap 5r 5w 58343 232524 readTime + writeTime = 290867 -*///:~ +*/ diff --git a/concurrency/MoreBasicThreads.java b/concurrency/MoreBasicThreads.java index 218cc9aa..09407c84 100644 --- a/concurrency/MoreBasicThreads.java +++ b/concurrency/MoreBasicThreads.java @@ -1,4 +1,4 @@ -//: concurrency/MoreBasicThreads.java +// concurrency/MoreBasicThreads.java // ©2015 MindView LLC: see Copyright.txt // Adding more threads. @@ -8,7 +8,8 @@ public class MoreBasicThreads { new Thread(new LiftOff()).start(); System.out.println("Waiting for LiftOff"); } -} /* Output: +} +/* Output: Waiting for LiftOff #3(9), #2(9), #3(8), #2(8), #3(7), #2(7), #3(6), #2(6), #3(5), #2(5), #3(4), #2(4), #3(3), #2(3), #3(2), #2(2), @@ -17,4 +18,4 @@ Waiting for LiftOff #4(6), #0(6), #1(5), #0(5), #4(5), #1(4), #4(4), #0(4), #1(3), #0(3), #4(3), #1(2), #4(2), #0(2), #1(1), #0(1), #4(1), #0(Liftoff!), #4(Liftoff!), #1(Liftoff!), -*///:~ +*/ diff --git a/concurrency/MultiLock.java b/concurrency/MultiLock.java index 9f2faea7..b3ffffbd 100644 --- a/concurrency/MultiLock.java +++ b/concurrency/MultiLock.java @@ -1,4 +1,4 @@ -//: concurrency/MultiLock.java +// concurrency/MultiLock.java // ©2015 MindView LLC: see Copyright.txt // One thread can reacquire the same lock. import static com.mindviewinc.util.Print.*; @@ -25,7 +25,8 @@ public class MultiLock { } }.start(); } -} /* Output: +} +/* Output: f1() calling f2() with count 9 f2() calling f1() with count 8 f1() calling f2() with count 7 @@ -36,4 +37,4 @@ f1() calling f2() with count 3 f2() calling f1() with count 2 f1() calling f2() with count 1 f2() calling f1() with count 0 -*///:~ +*/ diff --git a/concurrency/MutexEvenGenerator.java b/concurrency/MutexEvenGenerator.java index c56cc5e3..15e0fbfe 100644 --- a/concurrency/MutexEvenGenerator.java +++ b/concurrency/MutexEvenGenerator.java @@ -1,4 +1,4 @@ -//: concurrency/MutexEvenGenerator.java +// concurrency/MutexEvenGenerator.java // ©2015 MindView LLC: see Copyright.txt // Preventing thread collisions with mutexes. // {TimeOutDuringTesting} @@ -22,4 +22,5 @@ public class MutexEvenGenerator extends IntGenerator { public static void main(String[] args) { EvenChecker.test(new MutexEvenGenerator()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/concurrency/NIOInterruption.java b/concurrency/NIOInterruption.java index e0b3a056..b3cdbb48 100644 --- a/concurrency/NIOInterruption.java +++ b/concurrency/NIOInterruption.java @@ -1,4 +1,4 @@ -//: concurrency/NIOInterruption.java +// concurrency/NIOInterruption.java // ©2015 MindView LLC: see Copyright.txt // Interrupting a blocked NIO channel. import java.net.*; @@ -45,11 +45,12 @@ public class NIOInterruption { // Release the block by closing the channel: } } -} /* Output: +} +/* Output: Waiting for read() in NIOBlocked@14da8ff Waiting for read() in NIOBlocked@b280d5 ClosedByInterruptException Exiting NIOBlocked.run() NIOBlocked@14da8ff AsynchronousCloseException Exiting NIOBlocked.run() NIOBlocked@b280d5 -*///:~ +*/ diff --git a/concurrency/NaiveExceptionHandling.java b/concurrency/NaiveExceptionHandling.java index 97aa2417..79ce66cf 100644 --- a/concurrency/NaiveExceptionHandling.java +++ b/concurrency/NaiveExceptionHandling.java @@ -1,4 +1,4 @@ -//: concurrency/NaiveExceptionHandling.java +// concurrency/NaiveExceptionHandling.java // ©2015 MindView LLC: see Copyright.txt // {ValidateByHand} // {ThrowsException} @@ -15,4 +15,4 @@ public class NaiveExceptionHandling { System.out.println("Exception was handled!"); } } -} ///:~ +} diff --git a/concurrency/NotifyVsNotifyAll.java b/concurrency/NotifyVsNotifyAll.java index a3fa8411..e42290da 100644 --- a/concurrency/NotifyVsNotifyAll.java +++ b/concurrency/NotifyVsNotifyAll.java @@ -1,4 +1,4 @@ -//: concurrency/NotifyVsNotifyAll.java +// concurrency/NotifyVsNotifyAll.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.*; @@ -63,7 +63,8 @@ public class NotifyVsNotifyAll { System.out.println("\nShutting down"); exec.shutdownNow(); // Interrupt all tasks } -} /* Output: +} +/* Output: notify() Thread[pool-1-thread-1,5,main] notifyAll() Thread[pool-1-thread-1,5,main] Thread[pool-1-thread-5,5,main] @@ -103,4 +104,4 @@ Thread[pool-1-thread-5,5,main] Timer canceled Task2.blocker.prodAll() Thread[pool-1-thread-6,5,main] Shutting down -*///:~ +*/ diff --git a/concurrency/OrnamentalGarden.java b/concurrency/OrnamentalGarden.java index 10a95621..2095b921 100644 --- a/concurrency/OrnamentalGarden.java +++ b/concurrency/OrnamentalGarden.java @@ -1,4 +1,4 @@ -//: concurrency/OrnamentalGarden.java +// concurrency/OrnamentalGarden.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.*; @@ -78,7 +78,8 @@ public class OrnamentalGarden { print("Total: " + Entrance.getTotalCount()); print("Sum of Entrances: " + Entrance.sumEntrances()); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Entrance 0: 1 Total: 1 Entrance 1: 1 Total: 2 Entrance 4: 1 Total: 5 @@ -100,4 +101,4 @@ Stopping Entrance 2: 30 Stopping Entrance 3: 30 Total: 150 Sum of Entrances: 150 -*///:~ +*/ diff --git a/concurrency/Philosopher.java b/concurrency/Philosopher.java index 5c984e12..c0a31cd6 100644 --- a/concurrency/Philosopher.java +++ b/concurrency/Philosopher.java @@ -1,4 +1,4 @@ -//: concurrency/Philosopher.java +// concurrency/Philosopher.java // ©2015 MindView LLC: see Copyright.txt // A dining philosopher import java.util.concurrent.*; @@ -45,4 +45,4 @@ public class Philosopher implements Runnable { } @Override public String toString() { return "Philosopher " + id; } -} ///:~ +} diff --git a/concurrency/PipedIO.java b/concurrency/PipedIO.java index 4743b562..9736e86c 100644 --- a/concurrency/PipedIO.java +++ b/concurrency/PipedIO.java @@ -1,4 +1,4 @@ -//: concurrency/PipedIO.java +// concurrency/PipedIO.java // ©2015 MindView LLC: see Copyright.txt // Using pipes for inter-task I/O import java.util.concurrent.*; @@ -54,10 +54,11 @@ public class PipedIO { TimeUnit.SECONDS.sleep(4); exec.shutdownNow(); } -} /* Output: +} +/* Output: Read: A, Read: B, Read: C, Read: D, Read: E, Read: F, Read: G, Read: H, Read: I, Read: J, Read: K, Read: L, Read: M, java.lang.InterruptedException: sleep interrupted Sender sleep interrupted java.io.InterruptedIOException Receiver read exception -*///:~ +*/ diff --git a/concurrency/Pool.java b/concurrency/Pool.java index 8e68cac4..ce257cb7 100644 --- a/concurrency/Pool.java +++ b/concurrency/Pool.java @@ -1,4 +1,4 @@ -//: concurrency/Pool.java +// concurrency/Pool.java // ©2015 MindView LLC: see Copyright.txt // Using a Semaphore inside a Pool, to restrict // the number of tasks that can use a resource. @@ -49,4 +49,4 @@ public class Pool { } return false; // Wasn't checked out } -} ///:~ +} diff --git a/concurrency/PriorityBlockingQueueDemo.java b/concurrency/PriorityBlockingQueueDemo.java index 1af3730f..4aae39d1 100644 --- a/concurrency/PriorityBlockingQueueDemo.java +++ b/concurrency/PriorityBlockingQueueDemo.java @@ -1,4 +1,4 @@ -//: concurrency/PriorityBlockingQueueDemo.java +// concurrency/PriorityBlockingQueueDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.*; @@ -121,7 +121,8 @@ public class PriorityBlockingQueueDemo { exec.execute(new PrioritizedTaskProducer(queue, exec)); exec.execute(new PrioritizedTaskConsumer(queue)); } -} /* Output: (First and last 12 Lines) +} +/* Output: (First and last 12 Lines) [8 ] Task 0 [9 ] Task 5 [9 ] Task 13 @@ -147,4 +148,4 @@ ________...________...________...________...________ (40:-1) [-1 ] Task 40 Calling shutdownNow() Finished PrioritizedTaskConsumer -*///:~ +*/ diff --git a/concurrency/ReaderWriterList.java b/concurrency/ReaderWriterList.java index b36e5bbe..06078321 100644 --- a/concurrency/ReaderWriterList.java +++ b/concurrency/ReaderWriterList.java @@ -1,4 +1,4 @@ -//: concurrency/ReaderWriterList.java +// concurrency/ReaderWriterList.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; import java.util.concurrent.locks.*; @@ -83,7 +83,8 @@ class ReaderWriterListTest { for(int i = 0; i < writers; i++) exec.execute(new Writer()); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) 6 15 14 @@ -105,4 +106,4 @@ ________...________...________...________...________ 28 27 26 -*///:~ +*/ diff --git a/concurrency/ResponsiveUI.java b/concurrency/ResponsiveUI.java index ba2d8088..dbacf801 100644 --- a/concurrency/ResponsiveUI.java +++ b/concurrency/ResponsiveUI.java @@ -1,4 +1,4 @@ -//: concurrency/ResponsiveUI.java +// concurrency/ResponsiveUI.java // ©2015 MindView LLC: see Copyright.txt // User interface responsiveness. // {TimeOutDuringTesting} @@ -30,4 +30,5 @@ public class ResponsiveUI extends Thread { System.in.read(); System.out.println(d); // Shows progress } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/concurrency/Restaurant.java b/concurrency/Restaurant.java index bddb71d3..93c76754 100644 --- a/concurrency/Restaurant.java +++ b/concurrency/Restaurant.java @@ -1,4 +1,4 @@ -//: concurrency/Restaurant.java +// concurrency/Restaurant.java // ©2015 MindView LLC: see Copyright.txt // The producer-consumer approach to task cooperation. import java.util.concurrent.*; @@ -75,7 +75,8 @@ public class Restaurant { public static void main(String[] args) { new Restaurant(); } -} /* Output: +} +/* Output: Order up! Waitperson got Meal 1 Order up! Waitperson got Meal 2 Order up! Waitperson got Meal 3 @@ -88,4 +89,4 @@ Order up! Waitperson got Meal 9 Out of food, closing Order up! WaitPerson interrupted Chef interrupted -*///:~ +*/ diff --git a/concurrency/SelfManaged.java b/concurrency/SelfManaged.java index 6431c7d9..9b66a94c 100644 --- a/concurrency/SelfManaged.java +++ b/concurrency/SelfManaged.java @@ -1,4 +1,4 @@ -//: concurrency/SelfManaged.java +// concurrency/SelfManaged.java // ©2015 MindView LLC: see Copyright.txt // A Runnable containing its own driver Thread. @@ -23,7 +23,8 @@ public class SelfManaged implements Runnable { for(int i = 0; i < 5; i++) new SelfManaged(); } -} /* Output: +} +/* Output: Thread-0(5), Thread-4(5), Thread-3(5), Thread-1(5), Thread-2(5), Thread-2(4), Thread-2(3), Thread-1(4), Thread-3(4), Thread-4(4), Thread-0(4), Thread-4(3), @@ -31,4 +32,4 @@ Thread-3(3), Thread-1(3), Thread-2(2), Thread-1(2), Thread-3(2), Thread-4(2), Thread-0(3), Thread-4(1), Thread-3(1), Thread-1(1), Thread-2(1), Thread-0(2), Thread-0(1), -*///:~ +*/ diff --git a/concurrency/SemaphoreDemo.java b/concurrency/SemaphoreDemo.java index f0bd112b..84e7ab3b 100644 --- a/concurrency/SemaphoreDemo.java +++ b/concurrency/SemaphoreDemo.java @@ -1,4 +1,4 @@ -//: concurrency/SemaphoreDemo.java +// concurrency/SemaphoreDemo.java // ©2015 MindView LLC: see Copyright.txt // Testing the Pool class import java.util.concurrent.*; @@ -65,7 +65,8 @@ public class SemaphoreDemo { pool.checkIn(f); // Second checkIn ignored exec.shutdown(); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) CheckoutTask 4 checked out Fat id: 2 CheckoutTask 22 checked out Fat id: 24 CheckoutTask 14 checked out Fat id: 23 @@ -92,4 +93,4 @@ Fat id: 17, Fat id: 16, Fat id: 15, Fat id: 14, Fat id: 13, Fat id: 11, Fat id: 12, Fat id: 9, Fat id: 10, Fat id: 8, Fat id: 7, Fat id: 6, Fat id: 5, Fat id: 1, Fat id: 3, Fat id: 0, Fat id: 4] -*///:~ +*/ diff --git a/concurrency/SerialNumberChecker.java b/concurrency/SerialNumberChecker.java index 17f7b4f9..6e5b951e 100644 --- a/concurrency/SerialNumberChecker.java +++ b/concurrency/SerialNumberChecker.java @@ -1,4 +1,4 @@ -//: concurrency/SerialNumberChecker.java +// concurrency/SerialNumberChecker.java // ©2015 MindView LLC: see Copyright.txt // Operations that might seem safe are not, // when threads are present. @@ -60,7 +60,8 @@ public class SerialNumberChecker { System.exit(0); } } -} /* Output: +} +/* Output: Duplicate: 5453 Duplicate: 5639 -*///:~ +*/ diff --git a/concurrency/SerialNumberGenerator.java b/concurrency/SerialNumberGenerator.java index 56f6828b..c62aa488 100644 --- a/concurrency/SerialNumberGenerator.java +++ b/concurrency/SerialNumberGenerator.java @@ -1,4 +1,4 @@ -//: concurrency/SerialNumberGenerator.java +// concurrency/SerialNumberGenerator.java // ©2015 MindView LLC: see Copyright.txt public class SerialNumberGenerator { @@ -6,4 +6,4 @@ public class SerialNumberGenerator { public static int nextSerialNumber() { return serialNumber++; // Not thread-safe } -} ///:~ +} diff --git a/concurrency/SettingDefaultHandler.java b/concurrency/SettingDefaultHandler.java index 8480bd6c..eee0b743 100644 --- a/concurrency/SettingDefaultHandler.java +++ b/concurrency/SettingDefaultHandler.java @@ -1,4 +1,4 @@ -//: concurrency/SettingDefaultHandler.java +// concurrency/SettingDefaultHandler.java // ©2015 MindView LLC: see Copyright.txt // {TimeOutDuringTesting} import java.util.concurrent.*; @@ -10,6 +10,7 @@ public class SettingDefaultHandler { ExecutorService exec = Executors.newCachedThreadPool(); exec.execute(new ExceptionThread()); } -} /* Output: +} +/* Output: caught java.lang.RuntimeException -*///:~ +*/ diff --git a/concurrency/SimpleDaemons.java b/concurrency/SimpleDaemons.java index 17a89f72..4548337c 100644 --- a/concurrency/SimpleDaemons.java +++ b/concurrency/SimpleDaemons.java @@ -1,4 +1,4 @@ -//: concurrency/SimpleDaemons.java +// concurrency/SimpleDaemons.java // ©2015 MindView LLC: see Copyright.txt // Daemon threads don't prevent the program from ending. import java.util.concurrent.*; @@ -25,7 +25,8 @@ public class SimpleDaemons implements Runnable { print("All daemons started"); TimeUnit.MILLISECONDS.sleep(175); } -} /* Output: +} +/* Output: All daemons started Thread[Thread-6,5,main] SimpleDaemons@b87187 Thread[Thread-4,5,main] SimpleDaemons@1fb28c1 @@ -37,4 +38,4 @@ Thread[Thread-3,5,main] SimpleDaemons@4683f2 Thread[Thread-2,5,main] SimpleDaemons@4f80f2 Thread[Thread-5,5,main] SimpleDaemons@29c11d Thread[Thread-1,5,main] SimpleDaemons@9df74c -*///:~ +*/ diff --git a/concurrency/SimpleMicroBenchmark.java b/concurrency/SimpleMicroBenchmark.java index d684717d..85e02289 100644 --- a/concurrency/SimpleMicroBenchmark.java +++ b/concurrency/SimpleMicroBenchmark.java @@ -1,4 +1,4 @@ -//: concurrency/SimpleMicroBenchmark.java +// concurrency/SimpleMicroBenchmark.java // ©2015 MindView LLC: see Copyright.txt // The dangers of microbenchmarking. import java.util.concurrent.locks.*; @@ -41,8 +41,9 @@ public class SimpleMicroBenchmark { System.out.printf("Lock/synchronized = %1$.3f", (double)lockTime/(double)synchTime); } -} /* Output: +} +/* Output: synchronized: 243572959 Lock: 365176719 Lock/synchronized = 1.499 -*///:~ +*/ diff --git a/concurrency/SimplePriorities.java b/concurrency/SimplePriorities.java index e88c7750..b1650bc7 100644 --- a/concurrency/SimplePriorities.java +++ b/concurrency/SimplePriorities.java @@ -1,4 +1,4 @@ -//: concurrency/SimplePriorities.java +// concurrency/SimplePriorities.java // ©2015 MindView LLC: see Copyright.txt // Shows thread priorities. import java.util.concurrent.*; @@ -37,7 +37,8 @@ public class SimplePriorities implements Runnable { new SimplePriorities(Thread.MAX_PRIORITY)); exec.shutdown(); } -} /* Output: (First 10 Lines) +} +/* Output: (First 10 Lines) Thread[pool-1-thread-6,10,main]: 5 Thread[pool-1-thread-1,1,main]: 5 Thread[pool-1-thread-4,1,main]: 5 @@ -49,4 +50,4 @@ Thread[pool-1-thread-5,1,main]: 4 Thread[pool-1-thread-4,1,main]: 4 Thread[pool-1-thread-1,1,main]: 4 ... -*///:~ +*/ diff --git a/concurrency/SimpleThread.java b/concurrency/SimpleThread.java index 31989fd1..1aa00fe4 100644 --- a/concurrency/SimpleThread.java +++ b/concurrency/SimpleThread.java @@ -1,4 +1,4 @@ -//: concurrency/SimpleThread.java +// concurrency/SimpleThread.java // ©2015 MindView LLC: see Copyright.txt // Inheriting directly from the Thread class. @@ -26,9 +26,10 @@ public class SimpleThread extends Thread { for(int i = 0; i < 5; i++) new SimpleThread(); } -} /* Output: +} +/* Output: #4(5), #3(5), #5(5), #2(5), #2(4), #1(5), #4(4), #1(4), #2(3), #2(2), #5(4), #3(4), #3(3), #3(2), #5(3), #5(2), #2(1), #1(3), #4(3), #4(2), #1(2), #1(1), #5(1), #3(1), #4(1), -*///:~ +*/ diff --git a/concurrency/SingleThreadExecutor.java b/concurrency/SingleThreadExecutor.java index ef12b6cd..0c51f8c6 100644 --- a/concurrency/SingleThreadExecutor.java +++ b/concurrency/SingleThreadExecutor.java @@ -1,4 +1,4 @@ -//: concurrency/SingleThreadExecutor.java +// concurrency/SingleThreadExecutor.java // ©2015 MindView LLC: see Copyright.txt import java.util.concurrent.*; @@ -10,7 +10,8 @@ public class SingleThreadExecutor { exec.execute(new LiftOff()); exec.shutdown(); } -} /* Output: +} +/* Output: #0(9), #0(8), #0(7), #0(6), #0(5), #0(4), #0(3), #0(2), #0(1), #0(Liftoff!), #1(9), #1(8), #1(7), #1(6), #1(5), #1(4), #1(3), #1(2), #1(1), #1(Liftoff!), #2(9), #2(8), @@ -18,4 +19,4 @@ public class SingleThreadExecutor { #2(Liftoff!), #3(9), #3(8), #3(7), #3(6), #3(5), #3(4), #3(3), #3(2), #3(1), #3(Liftoff!), #4(9), #4(8), #4(7), #4(6), #4(5), #4(4), #4(3), #4(2), #4(1), #4(Liftoff!), -*///:~ +*/ diff --git a/concurrency/SleepingTask.java b/concurrency/SleepingTask.java index 2058d07a..a1312446 100644 --- a/concurrency/SleepingTask.java +++ b/concurrency/SleepingTask.java @@ -1,4 +1,4 @@ -//: concurrency/SleepingTask.java +// concurrency/SleepingTask.java // ©2015 MindView LLC: see Copyright.txt // Calling sleep() to pause for a while. import java.util.concurrent.*; @@ -24,7 +24,8 @@ public class SleepingTask extends LiftOff { exec.execute(new SleepingTask()); exec.shutdown(); } -} /* Output: +} +/* Output: #2(9), #4(9), #3(9), #0(9), #1(9), #2(8), #4(8), #3(8), #0(8), #1(8), #4(7), #3(7), #2(7), #1(7), #0(7), #4(6), #3(6), #2(6), #0(6), #1(6), #4(5), #2(5), #3(5), #1(5), @@ -32,4 +33,4 @@ public class SleepingTask extends LiftOff { #3(3), #1(3), #0(3), #4(2), #2(2), #3(2), #0(2), #1(2), #2(1), #4(1), #3(1), #0(1), #1(1), #2(Liftoff!), #4(Liftoff!), #3(Liftoff!), #0(Liftoff!), #1(Liftoff!), -*///:~ +*/ diff --git a/concurrency/SyncObject.java b/concurrency/SyncObject.java index b82e2207..7bfd7fd5 100644 --- a/concurrency/SyncObject.java +++ b/concurrency/SyncObject.java @@ -1,4 +1,4 @@ -//: concurrency/SyncObject.java +// concurrency/SyncObject.java // ©2015 MindView LLC: see Copyright.txt // Synchronizing on another object. import static com.mindviewinc.util.Print.*; @@ -32,7 +32,8 @@ public class SyncObject { }.start(); ds.g(); } -} /* Output: +} +/* Output: f() g() g() @@ -43,4 +44,4 @@ g() f() f() g() -*///:~ +*/ diff --git a/concurrency/SynchronizationComparisons.java b/concurrency/SynchronizationComparisons.java index c7886c2c..1f4d5d21 100644 --- a/concurrency/SynchronizationComparisons.java +++ b/concurrency/SynchronizationComparisons.java @@ -1,4 +1,4 @@ -//: concurrency/SynchronizationComparisons.java +// concurrency/SynchronizationComparisons.java // ©2015 MindView LLC: see Copyright.txt // Comparing the performance of explicit Locks // and Atomics versus the synchronized keyword. @@ -168,7 +168,8 @@ public class SynchronizationComparisons { } Accumulator.exec.shutdown(); } -} /* Output: +} +/* Output: Warmup synch : 66040963 ============================ @@ -206,4 +207,4 @@ Lock : 413671821 Atomic : 963264943 synch/Lock : 2.63 synch/(Atomic-synch) : -8.64 -*///:~ +*/ diff --git a/concurrency/SynchronizedEvenGenerator.java b/concurrency/SynchronizedEvenGenerator.java index 2e15f81c..0fd89cfa 100644 --- a/concurrency/SynchronizedEvenGenerator.java +++ b/concurrency/SynchronizedEvenGenerator.java @@ -1,4 +1,4 @@ -//: concurrency/SynchronizedEvenGenerator.java +// concurrency/SynchronizedEvenGenerator.java // ©2015 MindView LLC: see Copyright.txt // Simplifying mutexes with the synchronized keyword. // {TimeOutDuringTesting} @@ -16,4 +16,5 @@ SynchronizedEvenGenerator extends IntGenerator { public static void main(String[] args) { EvenChecker.test(new SynchronizedEvenGenerator()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/concurrency/TestBlockingQueues.java b/concurrency/TestBlockingQueues.java index 239ec61d..788ddb7b 100644 --- a/concurrency/TestBlockingQueues.java +++ b/concurrency/TestBlockingQueues.java @@ -1,4 +1,4 @@ -//: concurrency/TestBlockingQueues.java +// concurrency/TestBlockingQueues.java // ©2015 MindView LLC: see Copyright.txt // {TimeOutDuringTesting} import java.util.concurrent.*; @@ -66,4 +66,5 @@ public class TestBlockingQueues { test("SynchronousQueue", // Size of 1 new SynchronousQueue<>()); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/concurrency/Tester.java b/concurrency/Tester.java index b1aa4918..8f59839a 100644 --- a/concurrency/Tester.java +++ b/concurrency/Tester.java @@ -1,4 +1,4 @@ -//: concurrency/Tester.java +// concurrency/Tester.java // ©2015 MindView LLC: see Copyright.txt // Framework to test performance of concurrency containers. import java.util.concurrent.*; @@ -73,4 +73,4 @@ public abstract class Tester { System.out.printf("%-27s %14s %14s\n", "Type", "Read time", "Write time"); } -} ///:~ +} diff --git a/concurrency/ThreadLocalVariableHolder.java b/concurrency/ThreadLocalVariableHolder.java index 9aae8bb8..721e5426 100644 --- a/concurrency/ThreadLocalVariableHolder.java +++ b/concurrency/ThreadLocalVariableHolder.java @@ -1,4 +1,4 @@ -//: concurrency/ThreadLocalVariableHolder.java +// concurrency/ThreadLocalVariableHolder.java // ©2015 MindView LLC: see Copyright.txt // Automatically giving each thread its own storage. import java.util.concurrent.*; @@ -42,7 +42,8 @@ public class ThreadLocalVariableHolder { TimeUnit.SECONDS.sleep(3); // Run for a while exec.shutdownNow(); // All Accessors will quit } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) #2: 9259 #1: 962 #3: 1862 @@ -64,4 +65,4 @@ ________...________...________...________...________ #1: 3032 #4: 8404 #2: 11098 -*///:~ +*/ diff --git a/concurrency/ThreadVariations.java b/concurrency/ThreadVariations.java index 4f79edef..7e5714b5 100644 --- a/concurrency/ThreadVariations.java +++ b/concurrency/ThreadVariations.java @@ -1,4 +1,4 @@ -//: concurrency/ThreadVariations.java +// concurrency/ThreadVariations.java // ©2015 MindView LLC: see Copyright.txt // Creating threads with inner classes. import java.util.concurrent.*; @@ -161,7 +161,8 @@ public class ThreadVariations { new InnerRunnable2("InnerRunnable2"); new ThreadMethod("ThreadMethod").runTask(); } -} /* Output: +} +/* Output: InnerThread1: 5 InnerThread2: 5 InnerThread1: 4 @@ -187,4 +188,4 @@ ThreadMethod: 4 ThreadMethod: 3 ThreadMethod: 2 ThreadMethod: 1 -*///:~ +*/ diff --git a/concurrency/ToastOMatic.java b/concurrency/ToastOMatic.java index 3e534989..1c68d16c 100644 --- a/concurrency/ToastOMatic.java +++ b/concurrency/ToastOMatic.java @@ -1,4 +1,4 @@ -//: concurrency/ToastOMatic.java +// concurrency/ToastOMatic.java // ©2015 MindView LLC: see Copyright.txt // A toaster that uses queues. import java.util.concurrent.*; @@ -136,7 +136,8 @@ public class ToastOMatic { TimeUnit.SECONDS.sleep(5); exec.shutdownNow(); } -} /* Output: +} +/* Output: Toast 0: DRY Toast 0: BUTTERED Toast 0: JAMMED @@ -205,4 +206,4 @@ Toaster interrupted Eater interrupted Toaster off Eater off -*///:~ +*/ diff --git a/concurrency/restaurant2/RestaurantWithQueues.java b/concurrency/restaurant2/RestaurantWithQueues.java index 81b29ae9..641a037c 100644 --- a/concurrency/restaurant2/RestaurantWithQueues.java +++ b/concurrency/restaurant2/RestaurantWithQueues.java @@ -1,4 +1,4 @@ -//: concurrency/restaurant2/RestaurantWithQueues.java +// concurrency/restaurant2/RestaurantWithQueues.java // ©2015 MindView LLC: see Copyright.txt // {Args: 5} package concurrency.restaurant2; @@ -198,7 +198,8 @@ public class RestaurantWithQueues { } exec.shutdownNow(); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) WaitPerson 0 received SPRING_ROLLS delivering to Customer 1 Customer 1 eating SPRING_ROLLS WaitPerson 3 received SPRING_ROLLS delivering to Customer 0 @@ -220,4 +221,4 @@ Customer 9 finished meal, leaving Customer 15 finished meal, leaving Customer 21 finished meal, leaving Customer 0 finished meal, leaving -*///:~ +*/ diff --git a/concurrency/waxomatic/WaxOMatic.java b/concurrency/waxomatic/WaxOMatic.java index 3de7547b..bda197b7 100644 --- a/concurrency/waxomatic/WaxOMatic.java +++ b/concurrency/waxomatic/WaxOMatic.java @@ -1,4 +1,4 @@ -//: concurrency/waxomatic/WaxOMatic.java +// concurrency/waxomatic/WaxOMatic.java // ©2015 MindView LLC: see Copyright.txt // Basic task cooperation. package concurrency.waxomatic; @@ -74,7 +74,8 @@ public class WaxOMatic { TimeUnit.SECONDS.sleep(5); // Run for a while... exec.shutdownNow(); // Interrupt all tasks } -} /* Output: +} +/* Output: Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! @@ -82,4 +83,4 @@ Wax Off! Wax On! Wax Off! Wax On! Exiting via interrupt Ending Wax On task Exiting via interrupt Ending Wax Off task -*///:~ +*/ diff --git a/concurrency/waxomatic2/WaxOMatic2.java b/concurrency/waxomatic2/WaxOMatic2.java index df561dc0..cb309a7a 100644 --- a/concurrency/waxomatic2/WaxOMatic2.java +++ b/concurrency/waxomatic2/WaxOMatic2.java @@ -1,4 +1,4 @@ -//: concurrency/waxomatic2/WaxOMatic2.java +// concurrency/waxomatic2/WaxOMatic2.java // ©2015 MindView LLC: see Copyright.txt // Using Lock and Condition objects. package concurrency.waxomatic2; @@ -95,7 +95,8 @@ public class WaxOMatic2 { TimeUnit.SECONDS.sleep(5); exec.shutdownNow(); } -} /* Output: +} +/* Output: Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! Wax Off! Wax On! @@ -103,4 +104,4 @@ Wax Off! Wax On! Wax Off! Wax On! Exiting via interrupt Exiting via interrupt Ending Wax On task Ending Wax Off task -*///:~ +*/ diff --git a/containers/AdapterMethodIdiom.java b/containers/AdapterMethodIdiom.java index 50705171..bbe79c5b 100644 --- a/containers/AdapterMethodIdiom.java +++ b/containers/AdapterMethodIdiom.java @@ -1,6 +1,6 @@ -//: containers/AdapterMethodIdiom.java +// containers/AdapterMethodIdiom.java // ©2015 MindView LLC: see Copyright.txt -// The "Adapter Method" idiom uses foreach +// The "Adapter Method" idiom uses `forEach` // with additional kinds of Iterables. import java.util.*; @@ -34,7 +34,8 @@ public class AdapterMethodIdiom { for(String s : ral.reversed()) System.out.print(s + " "); } -} /* Output: +} +/* Output: To be or not to be be to not or be To -*///:~ +*/ diff --git a/containers/AddingGroups.java b/containers/AddingGroups.java index ac2d2e86..841118f4 100644 --- a/containers/AddingGroups.java +++ b/containers/AddingGroups.java @@ -1,4 +1,4 @@ -//: containers/AddingGroups.java +// containers/AddingGroups.java // ©2015 MindView LLC: see Copyright.txt // Adding groups of elements to Collection objects. import java.util.*; @@ -19,4 +19,5 @@ public class AddingGroups { // list.add(21); // Runtime error because the // underlying array cannot be resized. } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/containers/ApplesAndOrangesWithGenerics.java b/containers/ApplesAndOrangesWithGenerics.java index e3aa44d4..91a5240d 100644 --- a/containers/ApplesAndOrangesWithGenerics.java +++ b/containers/ApplesAndOrangesWithGenerics.java @@ -1,4 +1,4 @@ -//: containers/ApplesAndOrangesWithGenerics.java +// containers/ApplesAndOrangesWithGenerics.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -12,15 +12,16 @@ public class ApplesAndOrangesWithGenerics { for(Apple apple : apples) { System.out.println(apple.id()); } - // Using foreach: + // Using forEach: for(Apple c : apples) System.out.println(c.id()); } -} /* Output: +} +/* Output: 0 1 2 0 1 2 -*///:~ +*/ diff --git a/containers/ApplesAndOrangesWithoutGenerics.java b/containers/ApplesAndOrangesWithoutGenerics.java index 662783e5..6c259f88 100644 --- a/containers/ApplesAndOrangesWithoutGenerics.java +++ b/containers/ApplesAndOrangesWithoutGenerics.java @@ -1,4 +1,4 @@ -//: containers/ApplesAndOrangesWithoutGenerics.java +// containers/ApplesAndOrangesWithoutGenerics.java // ©2015 MindView LLC: see Copyright.txt // Simple container use (suppressing compiler warnings) // {ThrowsException} @@ -25,11 +25,12 @@ public class ApplesAndOrangesWithoutGenerics { // Orange is detected only at run time } } -} /* Output: +} +/* Output: ___[ Error Output ]___ Exception in thread "main" java.lang.ClassCastException: Orange cannot be cast to Apple at ApplesAndOrangesWithoutGenerics.main(ApplesAndOr angesWithoutGenerics.java:23) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/containers/ArrayIsNotIterable.java b/containers/ArrayIsNotIterable.java index ddf18688..d12fc8ba 100644 --- a/containers/ArrayIsNotIterable.java +++ b/containers/ArrayIsNotIterable.java @@ -1,4 +1,4 @@ -//: containers/ArrayIsNotIterable.java +// containers/ArrayIsNotIterable.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -10,11 +10,12 @@ public class ArrayIsNotIterable { public static void main(String[] args) { test(Arrays.asList(1, 2, 3)); String[] strings = { "A", "B", "C" }; - // An array works in foreach, but it's not Iterable: + // An array works in forEach, but it's not Iterable: //! test(strings); // You must explicitly convert it to an Iterable: test(Arrays.asList(strings)); } -} /* Output: +} +/* Output: 1 2 3 A B C -*///:~ +*/ diff --git a/containers/AsListInference.java b/containers/AsListInference.java index 05ec5edf..19e3e1e5 100644 --- a/containers/AsListInference.java +++ b/containers/AsListInference.java @@ -1,4 +1,4 @@ -//: containers/AsListInference.java +// containers/AsListInference.java // ©2015 MindView LLC: see Copyright.txt // Arrays.asList() makes its best guess about type. import java.util.*; @@ -31,4 +31,5 @@ public class AsListInference { List snow4 = Arrays.asList( new Light(), new Heavy()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/containers/CollectionSequence.java b/containers/CollectionSequence.java index 0ecf3b6c..b2698ea8 100644 --- a/containers/CollectionSequence.java +++ b/containers/CollectionSequence.java @@ -1,4 +1,4 @@ -//: containers/CollectionSequence.java +// containers/CollectionSequence.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -29,7 +29,8 @@ extends AbstractCollection { InterfaceVsIterator.display(c); InterfaceVsIterator.display(c.iterator()); } -} /* Output: +} +/* Output: 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx -*///:~ +*/ diff --git a/containers/ContainerMethods.java b/containers/ContainerMethods.java index eb8e1ce7..7ba8492d 100644 --- a/containers/ContainerMethods.java +++ b/containers/ContainerMethods.java @@ -1,4 +1,4 @@ -//: containers/ContainerMethods.java +// containers/ContainerMethods.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -6,7 +6,8 @@ public class ContainerMethods { public static void main(String[] args) { ContainerMethodDifferences.main(args); } -} /* Output: +} +/* Output: Collection: [add, addAll, clear, contains, containsAll, equals, forEach, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, @@ -61,4 +62,4 @@ pollFirstEntry, lastKey, firstEntry, floorEntry, comparator, lastEntry] Interfaces in TreeMap: [NavigableMap, Cloneable, Serializable] -*///:~ +*/ diff --git a/containers/CrossContainerIteration.java b/containers/CrossContainerIteration.java index d50f9e55..f8665111 100644 --- a/containers/CrossContainerIteration.java +++ b/containers/CrossContainerIteration.java @@ -1,4 +1,4 @@ -//: containers/CrossContainerIteration.java +// containers/CrossContainerIteration.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -21,9 +21,10 @@ public class CrossContainerIteration { display(petsHS.iterator()); display(petsTS.iterator()); } -} /* Output: +} +/* Output: 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 5:Cymric 2:Cymric 7:Manx 1:Manx 3:Mutt 6:Pug 4:Pug 0:Rat -*///:~ +*/ diff --git a/containers/EnvironmentVariables.java b/containers/EnvironmentVariables.java index 818ecf98..ba08bd57 100644 --- a/containers/EnvironmentVariables.java +++ b/containers/EnvironmentVariables.java @@ -1,4 +1,4 @@ -//: containers/EnvironmentVariables.java +// containers/EnvironmentVariables.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -9,4 +9,5 @@ public class EnvironmentVariables { entry.getValue()); } } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/containers/ForEachCollections.java b/containers/ForEachCollections.java index 5abe5cd2..3ae080ff 100644 --- a/containers/ForEachCollections.java +++ b/containers/ForEachCollections.java @@ -1,6 +1,6 @@ -//: containers/ForEachCollections.java +// containers/ForEachCollections.java // ©2015 MindView LLC: see Copyright.txt -// All collections work with foreach. +// All collections work with forEach. import java.util.*; public class ForEachCollections { @@ -11,6 +11,7 @@ public class ForEachCollections { for(String s : cs) System.out.print("'" + s + "' "); } -} /* Output: +} +/* Output: 'Take' 'the' 'long' 'way' 'home' -*///:~ +*/ diff --git a/containers/GenericsAndUpcasting.java b/containers/GenericsAndUpcasting.java index fee30adf..8fb1d2b3 100644 --- a/containers/GenericsAndUpcasting.java +++ b/containers/GenericsAndUpcasting.java @@ -1,4 +1,4 @@ -//: containers/GenericsAndUpcasting.java +// containers/GenericsAndUpcasting.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -17,9 +17,10 @@ public class GenericsAndUpcasting { for(Apple c : apples) System.out.println(c); } -} /* Output: +} +/* Output: GrannySmith@19e0bfd Gala@139a55 Fuji@1db9742 Braeburn@106d69c -*///:~ +*/ diff --git a/containers/InterfaceVsIterator.java b/containers/InterfaceVsIterator.java index 89b45d43..6ee759d1 100644 --- a/containers/InterfaceVsIterator.java +++ b/containers/InterfaceVsIterator.java @@ -1,4 +1,4 @@ -//: containers/InterfaceVsIterator.java +// containers/InterfaceVsIterator.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -19,7 +19,7 @@ public class InterfaceVsIterator { public static void main(String[] args) { List petList = Pets.arrayList(8); Set petSet = new HashSet<>(petList); - Map petMap = new LinkedHashMap<>(); + Map petMap = new LinkedHashMap<>(); String[] names = ("Ralph, Eric, Robin, Lacey, " + "Britney, Sam, Spot, Fluffy").split(", "); for(int i = 0; i < names.length; i++) @@ -33,7 +33,8 @@ public class InterfaceVsIterator { display(petMap.values()); display(petMap.values().iterator()); } -} /* Output: +} +/* Output: 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx @@ -43,4 +44,4 @@ Britney=Pug, Sam=Cymric, Spot=Pug, Fluffy=Manx} [Ralph, Eric, Robin, Lacey, Britney, Sam, Spot, Fluffy] 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx -*///:~ +*/ diff --git a/containers/IterableClass.java b/containers/IterableClass.java index ea5e7c8e..e4305a97 100644 --- a/containers/IterableClass.java +++ b/containers/IterableClass.java @@ -1,6 +1,6 @@ -//: containers/IterableClass.java +// containers/IterableClass.java // ©2015 MindView LLC: see Copyright.txt -// Anything Iterable works with foreach. +// Anything Iterable works with forEach. import java.util.*; public class IterableClass implements Iterable { @@ -26,6 +26,7 @@ public class IterableClass implements Iterable { for(String s : new IterableClass()) System.out.print(s + " "); } -} /* Output: +} +/* Output: And that is how we know the Earth to be banana-shaped. -*///:~ +*/ diff --git a/containers/LinkedListFeatures.java b/containers/LinkedListFeatures.java index be907b99..f32d4fae 100644 --- a/containers/LinkedListFeatures.java +++ b/containers/LinkedListFeatures.java @@ -1,4 +1,4 @@ -//: containers/LinkedListFeatures.java +// containers/LinkedListFeatures.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -30,7 +30,8 @@ public class LinkedListFeatures { print("After addLast(): " + pets); print("pets.removeLast(): " + pets.removeLast()); } -} /* Output: +} +/* Output: [Rat, Manx, Cymric, Mutt, Pug] pets.getFirst(): Rat pets.element(): Rat @@ -44,4 +45,4 @@ After offer(): [Rat, Mutt, Pug, Cymric] After add(): [Rat, Mutt, Pug, Cymric, Pug] After addLast(): [Rat, Mutt, Pug, Cymric, Pug, Hamster] pets.removeLast(): Hamster -*///:~ +*/ diff --git a/containers/ListFeatures.java b/containers/ListFeatures.java index adf4beb3..7caa5e3a 100644 --- a/containers/ListFeatures.java +++ b/containers/ListFeatures.java @@ -1,4 +1,4 @@ -//: containers/ListFeatures.java +// containers/ListFeatures.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -59,7 +59,8 @@ public class ListFeatures { Pet[] pa = pets.toArray(new Pet[0]); print("23: " + pa[3].id()); } -} /* Output: +} +/* Output: 1: [Rat, Manx, Cymric, Mutt, Pug, Cymric, Pug] 2: [Rat, Manx, Cymric, Mutt, Pug, Cymric, Pug, Hamster] 3: true @@ -87,4 +88,4 @@ sub: [Mouse, Pug] 21: [Manx, Cymric, Rat, EgyptianMau] 22: EgyptianMau 23: 14 -*///:~ +*/ diff --git a/containers/ListIteration.java b/containers/ListIteration.java index 82694914..6c71d9a9 100644 --- a/containers/ListIteration.java +++ b/containers/ListIteration.java @@ -1,4 +1,4 @@ -//: containers/ListIteration.java +// containers/ListIteration.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -23,11 +23,12 @@ public class ListIteration { } System.out.println(pets); } -} /* Output: +} +/* Output: Rat, 1, 0; Manx, 2, 1; Cymric, 3, 2; Mutt, 4, 3; Pug, 5, 4; Cymric, 6, 5; Pug, 7, 6; Manx, 8, 7; 7 6 5 4 3 2 1 0 [Rat, Manx, Cymric, Mutt, Pug, Cymric, Pug, Manx] [Rat, Manx, Cymric, Cymric, Rat, EgyptianMau, Hamster, EgyptianMau] -*///:~ +*/ diff --git a/containers/MapOfList.java b/containers/MapOfList.java index 756e0610..750c96d2 100644 --- a/containers/MapOfList.java +++ b/containers/MapOfList.java @@ -1,4 +1,4 @@ -//: containers/MapOfList.java +// containers/MapOfList.java // ©2015 MindView LLC: see Copyright.txt package containers; import typeinfo.pets.*; @@ -10,15 +10,15 @@ public class MapOfList { petPeople = new HashMap<>(); static { petPeople.put(new Person("Dawn"), - Arrays.asList(new Cymric("Molly"),new Mutt("Spot"))); + Arrays.asList(new Cymric("Molly"), new Mutt("Spot"))); petPeople.put(new Person("Kate"), Arrays.asList(new Cat("Shackleton"), new Cat("Elsie May"), new Dog("Margrett"))); petPeople.put(new Person("Marilyn"), Arrays.asList( - new Pug("Louie aka Louis Snorkelstein Dupree"), - new Cat("Stanford aka Stinky el Negro"), - new Cat("Pinkola"))); + new Pug("Louie aka Louis Snorkelstein Dupree"), + new Cat("Stanford aka Stinky el Negro"), + new Cat("Pinkola"))); petPeople.put(new Person("Luke"), Arrays.asList(new Rat("Fuzzy"), new Rat("Fizzy"))); petPeople.put(new Person("Isaac"), @@ -33,7 +33,8 @@ public class MapOfList { print(" " + pet); } } -} /* Output: +} +/* Output: People: [Person Marilyn, Person Dawn, Person Luke, Person Isaac, Person Kate] Pets: [[Pug Louie aka Louis Snorkelstein Dupree, Cat @@ -56,4 +57,4 @@ Person Kate has: Cat Shackleton Cat Elsie May Dog Margrett -*///:~ +*/ diff --git a/containers/ModifyingArraysAsList.java b/containers/ModifyingArraysAsList.java index f277142a..0010d94e 100644 --- a/containers/ModifyingArraysAsList.java +++ b/containers/ModifyingArraysAsList.java @@ -1,4 +1,4 @@ -//: containers/ModifyingArraysAsList.java +// containers/ModifyingArraysAsList.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -19,11 +19,12 @@ public class ModifyingArraysAsList { System.out.println("After shuffling: " + list2); System.out.println("array: " + Arrays.toString(ia)); } -} /* Output: +} +/* Output: Before shuffling: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] After shuffling: [4, 6, 3, 1, 8, 7, 2, 5, 10, 9] array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Before shuffling: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] After shuffling: [9, 1, 6, 3, 7, 2, 5, 10, 4, 8] array: [9, 1, 6, 3, 7, 2, 5, 10, 4, 8] -*///:~ +*/ diff --git a/containers/MultiIterableClass.java b/containers/MultiIterableClass.java index 08fc782f..cc07c456 100644 --- a/containers/MultiIterableClass.java +++ b/containers/MultiIterableClass.java @@ -1,4 +1,4 @@ -//: containers/MultiIterableClass.java +// containers/MultiIterableClass.java // ©2015 MindView LLC: see Copyright.txt // Adding several Adapter Methods. import java.util.*; @@ -36,8 +36,9 @@ public class MultiIterableClass extends IterableClass { for(String s : mic) System.out.print(s + " "); } -} /* Output: +} +/* Output: banana-shaped. be to Earth the know we how is that And is banana-shaped. Earth that how the be And we know to And that is how we know the Earth to be banana-shaped. -*///:~ +*/ diff --git a/containers/NonCollectionSequence.java b/containers/NonCollectionSequence.java index 429e4763..2b87e311 100644 --- a/containers/NonCollectionSequence.java +++ b/containers/NonCollectionSequence.java @@ -1,4 +1,4 @@ -//: containers/NonCollectionSequence.java +// containers/NonCollectionSequence.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -27,6 +27,7 @@ public class NonCollectionSequence extends PetSequence { NonCollectionSequence nc = new NonCollectionSequence(); InterfaceVsIterator.display(nc.iterator()); } -} /* Output: +} +/* Output: 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx -*///:~ +*/ diff --git a/containers/PetMap.java b/containers/PetMap.java index 339c7aca..19ade11f 100644 --- a/containers/PetMap.java +++ b/containers/PetMap.java @@ -1,4 +1,4 @@ -//: containers/PetMap.java +// containers/PetMap.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -6,7 +6,7 @@ import static com.mindviewinc.util.Print.*; public class PetMap { public static void main(String[] args) { - Map petMap = new HashMap<>(); + Map petMap = new HashMap<>(); petMap.put("My Cat", new Cat("Molly")); petMap.put("My Dog", new Dog("Ginger")); petMap.put("My Hamster", new Hamster("Bosco")); @@ -16,10 +16,11 @@ public class PetMap { print(petMap.containsKey("My Dog")); print(petMap.containsValue(dog)); } -} /* Output: +} +/* Output: {My Dog=Dog Ginger, My Cat=Cat Molly, My Hamster=Hamster Bosco} Dog Ginger true true -*///:~ +*/ diff --git a/containers/PrintingContainers.java b/containers/PrintingContainers.java index ee45f0eb..51313013 100644 --- a/containers/PrintingContainers.java +++ b/containers/PrintingContainers.java @@ -1,4 +1,4 @@ -//: containers/PrintingContainers.java +// containers/PrintingContainers.java // ©2015 MindView LLC: see Copyright.txt // Containers print themselves automatically. import java.util.*; @@ -12,7 +12,7 @@ public class PrintingContainers { collection.add("dog"); return collection; } - static Map fill(Map map) { + static Map fill(Map map) { map.put("rat", "Fuzzy"); map.put("cat", "Rags"); map.put("dog", "Bosco"); @@ -29,7 +29,8 @@ public class PrintingContainers { print(fill(new TreeMap<>())); print(fill(new LinkedHashMap<>())); } -} /* Output: +} +/* Output: [rat, cat, dog, dog] [rat, cat, dog, dog] [rat, cat, dog] @@ -38,4 +39,4 @@ public class PrintingContainers { {rat=Fuzzy, cat=Rags, dog=Spot} {cat=Rags, dog=Spot, rat=Fuzzy} {rat=Fuzzy, cat=Rags, dog=Spot} -*///:~ +*/ diff --git a/containers/PriorityQueueDemo.java b/containers/PriorityQueueDemo.java index b73e16b7..d5c4aaec 100644 --- a/containers/PriorityQueueDemo.java +++ b/containers/PriorityQueueDemo.java @@ -1,4 +1,4 @@ -//: containers/PriorityQueueDemo.java +// containers/PriorityQueueDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -37,7 +37,8 @@ public class PriorityQueueDemo { new PriorityQueue<>(charSet); QueueDemo.printQ(characterPQ); } -} /* Output: +} +/* Output: 0 1 1 1 1 1 3 5 8 14 1 1 2 3 3 9 9 14 14 18 18 20 21 22 23 25 25 25 25 23 22 21 20 18 18 14 14 9 9 3 3 2 1 1 @@ -46,4 +47,4 @@ T U U U W W U U U T T S S S O O O O N N L I I H H F E E E D D C C C B A A A B C D E F H I L N O S T U W -*///:~ +*/ diff --git a/containers/QueueDemo.java b/containers/QueueDemo.java index 14771521..ce540300 100644 --- a/containers/QueueDemo.java +++ b/containers/QueueDemo.java @@ -1,4 +1,4 @@ -//: containers/QueueDemo.java +// containers/QueueDemo.java // ©2015 MindView LLC: see Copyright.txt // Upcasting to a Queue from a LinkedList. import java.util.*; @@ -20,7 +20,8 @@ public class QueueDemo { qc.offer(c); printQ(qc); } -} /* Output: +} +/* Output: 8 1 1 1 5 14 3 1 0 1 B r o n t o s a u r u s -*///:~ +*/ diff --git a/containers/SetOfInteger.java b/containers/SetOfInteger.java index 57a271e9..44b8ab13 100644 --- a/containers/SetOfInteger.java +++ b/containers/SetOfInteger.java @@ -1,4 +1,4 @@ -//: containers/SetOfInteger.java +// containers/SetOfInteger.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -10,7 +10,8 @@ public class SetOfInteger { intset.add(rand.nextInt(30)); System.out.println(intset); } -} /* Output: +} +/* Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] -*///:~ +*/ diff --git a/containers/SetOperations.java b/containers/SetOperations.java index 4e43b18e..dea290b3 100644 --- a/containers/SetOperations.java +++ b/containers/SetOperations.java @@ -1,4 +1,4 @@ -//: containers/SetOperations.java +// containers/SetOperations.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import static com.mindviewinc.util.Print.*; @@ -22,7 +22,8 @@ public class SetOperations { Collections.addAll(set1, "X Y Z".split(" ")); print("'X Y Z' added to set1: " + set1); } -} /* Output: +} +/* Output: H: true N: false set2 in set1: true @@ -30,4 +31,4 @@ set1: [A, B, C, D, E, F, G, I, J, K, L, M] set2 in set1: false set2 removed from set1: [A, B, C, D, E, F, G, M] 'X Y Z' added to set1: [A, B, C, D, E, F, G, M, X, Y, Z] -*///:~ +*/ diff --git a/containers/SimpleCollection.java b/containers/SimpleCollection.java index 2b79b3f4..6931b535 100644 --- a/containers/SimpleCollection.java +++ b/containers/SimpleCollection.java @@ -1,4 +1,4 @@ -//: containers/SimpleCollection.java +// containers/SimpleCollection.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -10,6 +10,7 @@ public class SimpleCollection { for(Integer i : c) System.out.print(i + ", "); } -} /* Output: +} +/* Output: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -*///:~ +*/ diff --git a/containers/SimpleIteration.java b/containers/SimpleIteration.java index 3b5f5600..306a2dc7 100644 --- a/containers/SimpleIteration.java +++ b/containers/SimpleIteration.java @@ -1,4 +1,4 @@ -//: containers/SimpleIteration.java +// containers/SimpleIteration.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -24,10 +24,11 @@ public class SimpleIteration { } System.out.println(pets); } -} /* Output: +} +/* Output: 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 8:Cymric 9:Rat 10:EgyptianMau 11:Hamster 0:Rat 1:Manx 2:Cymric 3:Mutt 4:Pug 5:Cymric 6:Pug 7:Manx 8:Cymric 9:Rat 10:EgyptianMau 11:Hamster [Pug, Manx, Cymric, Rat, EgyptianMau, Hamster] -*///:~ +*/ diff --git a/containers/SortedSetOfInteger.java b/containers/SortedSetOfInteger.java index 3c37e126..428adddf 100644 --- a/containers/SortedSetOfInteger.java +++ b/containers/SortedSetOfInteger.java @@ -1,4 +1,4 @@ -//: containers/SortedSetOfInteger.java +// containers/SortedSetOfInteger.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -10,7 +10,8 @@ public class SortedSetOfInteger { intset.add(rand.nextInt(30)); System.out.println(intset); } -} /* Output: +} +/* Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] -*///:~ +*/ diff --git a/containers/StackCollision.java b/containers/StackCollision.java index 436b7778..98c8f47b 100644 --- a/containers/StackCollision.java +++ b/containers/StackCollision.java @@ -1,4 +1,4 @@ -//: containers/StackCollision.java +// containers/StackCollision.java // ©2015 MindView LLC: see Copyright.txt public class StackCollision { @@ -17,7 +17,8 @@ public class StackCollision { while(!stack2.empty()) System.out.print(stack2.pop() + " "); } -} /* Output: +} +/* Output: fleas has dog My fleas has dog My -*///:~ +*/ diff --git a/containers/StackTest.java b/containers/StackTest.java index 624d3023..621e5538 100644 --- a/containers/StackTest.java +++ b/containers/StackTest.java @@ -1,4 +1,4 @@ -//: containers/StackTest.java +// containers/StackTest.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -10,6 +10,7 @@ public class StackTest { while(!stack.empty()) System.out.print(stack.pop() + " "); } -} /* Output: +} +/* Output: fleas has dog My -*///:~ +*/ diff --git a/containers/Statistics.java b/containers/Statistics.java index bd4ac2f5..266b7333 100644 --- a/containers/Statistics.java +++ b/containers/Statistics.java @@ -1,4 +1,4 @@ -//: containers/Statistics.java +// containers/Statistics.java // ©2015 MindView LLC: see Copyright.txt // Simple demonstration of HashMap. import java.util.*; @@ -6,7 +6,7 @@ import java.util.*; public class Statistics { public static void main(String[] args) { Random rand = new Random(47); - Map m = new HashMap<>(); + Map m = new HashMap<>(); for(int i = 0; i < 10000; i++) { // Produce a number between 0 and 20: int r = rand.nextInt(20); @@ -15,8 +15,9 @@ public class Statistics { } System.out.println(m); } -} /* Output: +} +/* Output: {0=481, 1=502, 2=489, 3=508, 4=481, 5=503, 6=519, 7=471, 8=468, 9=549, 10=513, 11=531, 12=521, 13=506, 14=477, 15=497, 16=533, 17=509, 18=478, 19=464} -*///:~ +*/ diff --git a/containers/UniqueWords.java b/containers/UniqueWords.java index 05da9e38..2260d8b0 100644 --- a/containers/UniqueWords.java +++ b/containers/UniqueWords.java @@ -1,4 +1,4 @@ -//: containers/UniqueWords.java +// containers/UniqueWords.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import com.mindviewinc.util.*; @@ -9,11 +9,12 @@ public class UniqueWords { new TextFile("SetOperations.java", "\\W+")); System.out.println(words); } -} /* Output: +} +/* Output: [A, B, C, Collections, D, E, F, G, H, HashSet, I, J, K, L, M, N, Output, Print, Set, SetOperations, String, X, Y, Z, add, addAll, added, args, class, com, containers, contains, containsAll, false, from, import, in, java, main, mindviewinc, new, print, public, remove, removeAll, removed, set1, set2, split, static, to, true, util, void] -*///:~ +*/ diff --git a/containers/UniqueWordsAlphabetic.java b/containers/UniqueWordsAlphabetic.java index 4ccedec4..c3b2f2b9 100644 --- a/containers/UniqueWordsAlphabetic.java +++ b/containers/UniqueWordsAlphabetic.java @@ -1,4 +1,4 @@ -//: containers/UniqueWordsAlphabetic.java +// containers/UniqueWordsAlphabetic.java // ©2015 MindView LLC: see Copyright.txt // Producing an alphabetic listing. import java.util.*; @@ -12,11 +12,12 @@ public class UniqueWordsAlphabetic { new TextFile("SetOperations.java", "\\W+")); System.out.println(words); } -} /* Output: +} +/* Output: [A, add, addAll, added, args, B, C, class, Collections, com, containers, contains, containsAll, D, E, F, false, from, G, H, HashSet, I, import, in, J, java, K, L, M, main, mindviewinc, N, new, Output, Print, public, remove, removeAll, removed, Set, set1, set2, SetOperations, split, static, String, to, true, util, void, X, Y, Z] -*///:~ +*/ diff --git a/containersindepth/AssociativeArray.java b/containersindepth/AssociativeArray.java index 166aff8a..ee8066e5 100644 --- a/containersindepth/AssociativeArray.java +++ b/containersindepth/AssociativeArray.java @@ -1,9 +1,9 @@ -//: containersindepth/AssociativeArray.java +// containersindepth/AssociativeArray.java // ©2015 MindView LLC: see Copyright.txt // Associates keys with values. import static com.mindviewinc.util.Print.*; -public class AssociativeArray { +public class AssociativeArray { private Object[][] pairs; private int index; public AssociativeArray(int length) { @@ -50,7 +50,8 @@ public class AssociativeArray { print(map); print(map.get("ocean")); } -} /* Output: +} +/* Output: Too many objects! sky : blue grass : green @@ -59,4 +60,4 @@ tree : tall earth : brown sun : warm dancing -*///:~ +*/ diff --git a/containersindepth/Bits.java b/containersindepth/Bits.java index a50d1385..71858618 100644 --- a/containersindepth/Bits.java +++ b/containersindepth/Bits.java @@ -1,4 +1,4 @@ -//: containersindepth/Bits.java +// containersindepth/Bits.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of BitSet. import java.util.*; @@ -57,7 +57,8 @@ public class Bits { b1023.set(1024); print("set bit 1023: " + b1023); } -} /* Output: +} +/* Output: byte value: -107 bits: {0, 2, 4, 7} bit pattern: 1010100100000000000000000000000000000000000000 @@ -74,4 +75,4 @@ bit pattern: 1101010101010000001101111110000100000000000000 set bit 127: {127} set bit 255: {255} set bit 1023: {1023, 1024} -*///:~ +*/ diff --git a/containersindepth/CanonicalMapping.java b/containersindepth/CanonicalMapping.java index 36857380..9e32937b 100644 --- a/containersindepth/CanonicalMapping.java +++ b/containersindepth/CanonicalMapping.java @@ -1,4 +1,4 @@ -//: containersindepth/CanonicalMapping.java +// containersindepth/CanonicalMapping.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates WeakHashMap. import java.util.*; @@ -47,4 +47,5 @@ public class CanonicalMapping { } System.gc(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/containersindepth/CollectionDataGeneration.java b/containersindepth/CollectionDataGeneration.java index bcdb2ef3..2f9c16f9 100644 --- a/containersindepth/CollectionDataGeneration.java +++ b/containersindepth/CollectionDataGeneration.java @@ -1,4 +1,4 @@ -//: containersindepth/CollectionDataGeneration.java +// containersindepth/CollectionDataGeneration.java // ©2015 MindView LLC: see Copyright.txt // Using the Generators defined in the Arrays chapter. import java.util.*; @@ -13,8 +13,9 @@ public class CollectionDataGeneration { new CollectionData<>( new RandomGenerator.Integer(), 10))); } -} /* Output: +} +/* Output: [YNzbrnyGc, FOWZnTcQr, GseGZMmJM, RoEsuEcUO, neOEdLsmw, HLGEahKcx, rEqUCBbkI, naMesbtWH, kjUrUkZPg, wsqPzDyCy] [2017, 8037, 871, 7882, 6090, 4779, 299, 573, 4367, 3455] -*///:~ +*/ diff --git a/containersindepth/CollectionDataTest.java b/containersindepth/CollectionDataTest.java index cc927308..09766409 100644 --- a/containersindepth/CollectionDataTest.java +++ b/containersindepth/CollectionDataTest.java @@ -1,4 +1,4 @@ -//: containersindepth/CollectionDataTest.java +// containersindepth/CollectionDataTest.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import com.mindviewinc.util.*; @@ -20,7 +20,8 @@ public class CollectionDataTest { set.addAll(CollectionData.list(new Government(), 15)); System.out.println(set); } -} /* Output: +} +/* Output: [strange, women, lying, in, ponds, distributing, swords, is, no, basis, for, a, system, of, government] -*///:~ +*/ diff --git a/containersindepth/CollectionMethods.java b/containersindepth/CollectionMethods.java index f1aa9760..11256808 100644 --- a/containersindepth/CollectionMethods.java +++ b/containersindepth/CollectionMethods.java @@ -1,4 +1,4 @@ -//: containersindepth/CollectionMethods.java +// containersindepth/CollectionMethods.java // ©2015 MindView LLC: see Copyright.txt // Things you can do with all Collections. import java.util.*; @@ -57,7 +57,8 @@ public class CollectionMethods { c.clear(); // Remove all elements print("after c.clear():" + c); } -} /* Output: +} +/* Output: [ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI, ten, eleven] Collections.max(c) = ten @@ -79,4 +80,4 @@ c.containsAll(c2) = true c2.isEmpty() = true [ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI] after c.clear():[] -*///:~ +*/ diff --git a/containersindepth/CountedString.java b/containersindepth/CountedString.java index cce26c0a..1a732523 100644 --- a/containersindepth/CountedString.java +++ b/containersindepth/CountedString.java @@ -1,4 +1,4 @@ -//: containersindepth/CountedString.java +// containersindepth/CountedString.java // ©2015 MindView LLC: see Copyright.txt // Creating a good hashCode(). import java.util.*; @@ -53,7 +53,8 @@ public class CountedString { print(map.get(cstring)); } } -} /* Output: +} +/* Output: {String: hi id: 4 hashCode(): 146450=3, String: hi id: 5 hashCode(): 146451=4, String: hi id: 2 hashCode(): 146448=1, String: hi id: 3 hashCode(): 146449=2, String: hi @@ -68,4 +69,4 @@ Looking up String: hi id: 4 hashCode(): 146450 3 Looking up String: hi id: 5 hashCode(): 146451 4 -*///:~ +*/ diff --git a/containersindepth/DequeTest.java b/containersindepth/DequeTest.java index e8b94aca..e1825504 100644 --- a/containersindepth/DequeTest.java +++ b/containersindepth/DequeTest.java @@ -1,4 +1,4 @@ -//: containersindepth/DequeTest.java +// containersindepth/DequeTest.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; import static com.mindviewinc.util.Print.*; @@ -21,8 +21,9 @@ public class DequeTest { while(di.size() != 0) printnb(di.removeLast() + " "); } -} /* Output: +} +/* Output: [26, 25, 24, 23, 22, 21, 20, 50, 51, 52, 53, 54] 26 25 24 23 22 21 20 50 51 52 53 54 54 53 52 51 50 20 21 22 23 24 25 26 -*///:~ +*/ diff --git a/containersindepth/Enumerations.java b/containersindepth/Enumerations.java index eb9f3aaa..aeb1e4c2 100644 --- a/containersindepth/Enumerations.java +++ b/containersindepth/Enumerations.java @@ -1,4 +1,4 @@ -//: containersindepth/Enumerations.java +// containersindepth/Enumerations.java // ©2015 MindView LLC: see Copyright.txt // Java 1.0/1.1 Vector and Enumeration. import java.util.*; @@ -14,7 +14,8 @@ public class Enumerations { // Produce an Enumeration from a Collection: e = Collections.enumeration(new ArrayList<>()); } -} /* Output: +} +/* Output: ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI, CAMEROON, CAPE VERDE, CENTRAL AFRICAN REPUBLIC, CHAD, -*///:~ +*/ diff --git a/containersindepth/FailFast.java b/containersindepth/FailFast.java index 70c11163..3e2a3c08 100644 --- a/containersindepth/FailFast.java +++ b/containersindepth/FailFast.java @@ -1,4 +1,4 @@ -//: containersindepth/FailFast.java +// containersindepth/FailFast.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates the "fail-fast" behavior. import java.util.*; @@ -14,6 +14,7 @@ public class FailFast { System.out.println(e); } } -} /* Output: +} +/* Output: java.util.ConcurrentModificationException -*///:~ +*/ diff --git a/containersindepth/FillingLists.java b/containersindepth/FillingLists.java index 2db70661..d36a33a9 100644 --- a/containersindepth/FillingLists.java +++ b/containersindepth/FillingLists.java @@ -1,4 +1,4 @@ -//: containersindepth/FillingLists.java +// containersindepth/FillingLists.java // ©2015 MindView LLC: see Copyright.txt // The Collections.fill() & Collections.nCopies() methods. import java.util.*; @@ -20,9 +20,10 @@ public class FillingLists { Collections.fill(list, new StringAddress("World!")); System.out.println(list); } -} /* Output: +} +/* Output: [StringAddress@19e0bfd Hello, StringAddress@19e0bfd Hello, StringAddress@19e0bfd Hello, StringAddress@19e0bfd Hello] [StringAddress@139a55 World!, StringAddress@139a55 World!, StringAddress@139a55 World!, StringAddress@139a55 World!] -*///:~ +*/ diff --git a/containersindepth/Groundhog.java b/containersindepth/Groundhog.java index 1f0fbcb2..60725a6d 100644 --- a/containersindepth/Groundhog.java +++ b/containersindepth/Groundhog.java @@ -1,4 +1,4 @@ -//: containersindepth/Groundhog.java +// containersindepth/Groundhog.java // ©2015 MindView LLC: see Copyright.txt // Looks plausible, but doesn't work as a HashMap key. @@ -9,4 +9,4 @@ public class Groundhog { public String toString() { return "Groundhog #" + number; } -} ///:~ +} diff --git a/containersindepth/Groundhog2.java b/containersindepth/Groundhog2.java index a5f58ed2..fa92ebfa 100644 --- a/containersindepth/Groundhog2.java +++ b/containersindepth/Groundhog2.java @@ -1,4 +1,4 @@ -//: containersindepth/Groundhog2.java +// containersindepth/Groundhog2.java // ©2015 MindView LLC: see Copyright.txt // A class that's used as a key in a HashMap // must override hashCode() and equals(). @@ -12,4 +12,4 @@ public class Groundhog2 extends Groundhog { return o instanceof Groundhog2 && (number == ((Groundhog2)o).number); } -} ///:~ +} diff --git a/containersindepth/IndividualTest.java b/containersindepth/IndividualTest.java index 726f233a..e3456066 100644 --- a/containersindepth/IndividualTest.java +++ b/containersindepth/IndividualTest.java @@ -1,4 +1,4 @@ -//: containersindepth/IndividualTest.java +// containersindepth/IndividualTest.java // ©2015 MindView LLC: see Copyright.txt import containers.MapOfList; import typeinfo.pets.*; @@ -13,9 +13,10 @@ public class IndividualTest { pets.add(p); System.out.println(pets); } -} /* Output: +} +/* Output: [Cat Elsie May, Cat Pinkola, Cat Shackleton, Cat Stanford aka Stinky el Negro, Cymric Molly, Dog Margrett, Mutt Spot, Pug Louie aka Louis Snorkelstein Dupree, Rat Fizzy, Rat Freckly, Rat Fuzzy] -*///:~ +*/ diff --git a/containersindepth/LinkedHashMapDemo.java b/containersindepth/LinkedHashMapDemo.java index 1adbd752..acff11c1 100644 --- a/containersindepth/LinkedHashMapDemo.java +++ b/containersindepth/LinkedHashMapDemo.java @@ -1,4 +1,4 @@ -//: containersindepth/LinkedHashMapDemo.java +// containersindepth/LinkedHashMapDemo.java // ©2015 MindView LLC: see Copyright.txt // What you can do with a LinkedHashMap. import java.util.*; @@ -20,9 +20,10 @@ public class LinkedHashMapDemo { linkedMap.get(0); print(linkedMap); } -} /* Output: +} +/* Output: {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0} {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0} {6=G0, 7=H0, 8=I0, 0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0} {6=G0, 7=H0, 8=I0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 0=A0} -*///:~ +*/ diff --git a/containersindepth/ListPerformance.java b/containersindepth/ListPerformance.java index 638b1fa0..69610fe8 100644 --- a/containersindepth/ListPerformance.java +++ b/containersindepth/ListPerformance.java @@ -1,4 +1,4 @@ -//: containersindepth/ListPerformance.java +// containersindepth/ListPerformance.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates performance differences in Lists. // {Args: 100 500} Small to keep build testing short @@ -185,20 +185,21 @@ public class ListPerformance { qTest.setHeadline("Queue tests"); qTest.timedTest(); } -} /* Output: +} +/* Output: --- Array as List --- - size get set +size get set 100 34 32 --------------------- ArrayList --------------------- - size add get set iteradd insert remove +size add get set iteradd insert remove 100 48 27 36 54 225 167 --------------------- LinkedList --------------------- - size add get set iteradd insert remove +size add get set iteradd insert remove 100 63 64 77 125 219 97 ----------------------- Vector ----------------------- - size add get set iteradd insert remove +size add get set iteradd insert remove 100 35 48 49 117 213 98 -------------------- Queue tests -------------------- - size addFirst addLast rmFirst rmLast +size addFirst addLast rmFirst rmLast 100 49 95 78 74 -*///:~ +*/ diff --git a/containersindepth/ListSortSearch.java b/containersindepth/ListSortSearch.java index 0fd2e173..cff43f32 100644 --- a/containersindepth/ListSortSearch.java +++ b/containersindepth/ListSortSearch.java @@ -1,4 +1,4 @@ -//: containersindepth/ListSortSearch.java +// containersindepth/ListSortSearch.java // ©2015 MindView LLC: see Copyright.txt // Sorting and searching Lists with Collections utilities. import java.util.*; @@ -33,7 +33,8 @@ public class ListSortSearch { print("Location of " + key + " is " + index + ", list.get(" + index + ") = " + list.get(index)); } -} /* Output: +} +/* Output: [one, Two, three, Four, five, six, one, one, Two, three, Four, five, six, one] Shuffled: [Four, five, one, one, Two, six, six, three, @@ -46,4 +47,4 @@ Location of six is 7, list.get(7) = six Case-insensitive sorted: [five, five, Four, one, one, six, six, three, three, Two] Location of three is 7, list.get(7) = three -*///:~ +*/ diff --git a/containersindepth/Lists.java b/containersindepth/Lists.java index 37084fa7..edeb3edc 100644 --- a/containersindepth/Lists.java +++ b/containersindepth/Lists.java @@ -1,4 +1,4 @@ -//: containersindepth/Lists.java +// containersindepth/Lists.java // ©2015 MindView LLC: see Copyright.txt // Things you can do with Lists. import java.util.*; @@ -123,7 +123,8 @@ public class Lists { new LinkedList<>(Countries.names(25))); testLinkedList(); } -} /* Output: (First and last 2 Lines) +} +/* Output: (First and last 2 Lines) [ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI, CAMEROON, CAPE VERDE, CENTRAL AFRICAN REPUBLIC, CHAD, COMOROS, CONGO, DJIBOUTI, EGYPT, EQUATORIAL GUINEA, @@ -141,4 +142,4 @@ CAMEROON, CAPE VERDE, CENTRAL AFRICAN REPUBLIC, CHAD, COMOROS, CONGO, DJIBOUTI, EGYPT, EQUATORIAL GUINEA, ERITREA, ETHIOPIA, GABON, THE GAMBIA, GHANA, GUINEA, BISSAU, COTE D'IVOIR (IVORY COAST), KENYA] -*///:~ +*/ diff --git a/containersindepth/MapDataTest.java b/containersindepth/MapDataTest.java index 8329dc66..ce143e63 100644 --- a/containersindepth/MapDataTest.java +++ b/containersindepth/MapDataTest.java @@ -1,4 +1,4 @@ -//: containersindepth/MapDataTest.java +// containersindepth/MapDataTest.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import com.mindviewinc.util.*; @@ -44,10 +44,11 @@ public class MapDataTest { // An Iterable and a single value: print(MapData.map(new Letters(), "Pop")); } -} /* Output: +} +/* Output: {1=A, 2=B, 3=C, 4=D, 5=E, 6=F, 7=G, 8=H, 9=I, 10=J, 11=K} {a=YNz, b=brn, c=yGc, d=FOW, e=ZnT, f=cQr, g=Gse, h=GZM} {a=Value, b=Value, c=Value, d=Value, e=Value, f=Value} {1=mJM, 2=RoE, 3=suE, 4=cUO, 5=neO, 6=EdL, 7=smw, 8=HLG} {1=Pop, 2=Pop, 3=Pop, 4=Pop, 5=Pop, 6=Pop, 7=Pop, 8=Pop} -*///:~ +*/ diff --git a/containersindepth/MapEntry.java b/containersindepth/MapEntry.java index 70b063ca..7cf79b69 100644 --- a/containersindepth/MapEntry.java +++ b/containersindepth/MapEntry.java @@ -1,9 +1,9 @@ -//: containersindepth/MapEntry.java +// containersindepth/MapEntry.java // ©2015 MindView LLC: see Copyright.txt // A simple Map.Entry for sample Map implementations. import java.util.*; -public class MapEntry implements Map.Entry { +public class MapEntry implements Map.Entry { private K key; private V value; public MapEntry(K key, V value) { @@ -29,7 +29,7 @@ public class MapEntry implements Map.Entry { public boolean equals(Object o) { if(!(o instanceof MapEntry)) return false; @SuppressWarnings("unchecked") - MapEntry me = (MapEntry)o; + MapEntry me = (MapEntry)o; return (key == null ? me.getKey() == null : key.equals(me.getKey())) && @@ -38,4 +38,4 @@ public class MapEntry implements Map.Entry { } @Override public String toString() { return key + "=" + value; } -} ///:~ +} diff --git a/containersindepth/MapPerformance.java b/containersindepth/MapPerformance.java index 17555c90..fda5210d 100644 --- a/containersindepth/MapPerformance.java +++ b/containersindepth/MapPerformance.java @@ -1,4 +1,4 @@ -//: containersindepth/MapPerformance.java +// containersindepth/MapPerformance.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates performance differences in Maps. // {Args: 100 5000} Small to keep build testing short @@ -56,23 +56,24 @@ public class MapPerformance { Tester.run(new WeakHashMap<>(), tests); Tester.run(new Hashtable<>(), tests); } -} /* Output: +} +/* Output: ---------- TreeMap ---------- - size put get iterate +size put get iterate 100 137 99 24 ---------- HashMap ---------- - size put get iterate +size put get iterate 100 47 19 29 ------- LinkedHashMap ------- - size put get iterate +size put get iterate 100 59 13 11 ------ IdentityHashMap ------ - size put get iterate +size put get iterate 100 74 71 23 -------- WeakHashMap -------- - size put get iterate +size put get iterate 100 43 16 15 --------- Hashtable --------- - size put get iterate +size put get iterate 100 32 27 17 -*///:~ +*/ diff --git a/containersindepth/Maps.java b/containersindepth/Maps.java index 2d672a97..e6ed35f3 100644 --- a/containersindepth/Maps.java +++ b/containersindepth/Maps.java @@ -1,4 +1,4 @@ -//: containersindepth/Maps.java +// containersindepth/Maps.java // ©2015 MindView LLC: see Copyright.txt // Things you can do with Maps. import java.util.concurrent.*; @@ -45,7 +45,8 @@ public class Maps { test(new ConcurrentHashMap<>()); test(new WeakHashMap<>()); } -} /* Output: (First 11 Lines) +} +/* Output: (First 11 Lines) HashMap Size = 25, Keys: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] @@ -63,4 +64,4 @@ Size = 24, Keys: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, map.isEmpty(): true map.isEmpty(): true ... -*///:~ +*/ diff --git a/containersindepth/Prediction.java b/containersindepth/Prediction.java index bc3825d4..adf321b3 100644 --- a/containersindepth/Prediction.java +++ b/containersindepth/Prediction.java @@ -1,4 +1,4 @@ -//: containersindepth/Prediction.java +// containersindepth/Prediction.java // ©2015 MindView LLC: see Copyright.txt // Predicting the weather with groundhogs. import java.util.*; @@ -13,4 +13,4 @@ public class Prediction { else return "Early Spring!"; } -} ///:~ +} diff --git a/containersindepth/QueueBehavior.java b/containersindepth/QueueBehavior.java index 514c2e6e..88e922e6 100644 --- a/containersindepth/QueueBehavior.java +++ b/containersindepth/QueueBehavior.java @@ -1,4 +1,4 @@ -//: containersindepth/QueueBehavior.java +// containersindepth/QueueBehavior.java // ©2015 MindView LLC: see Copyright.txt // Compares the behavior of some of the queues import java.util.concurrent.*; @@ -29,11 +29,12 @@ public class QueueBehavior { test(new LinkedBlockingQueue<>(), new Gen()); test(new PriorityBlockingQueue<>(), new Gen()); } -} /* Output: +} +/* Output: one two three four five six seven eight nine ten eight five four nine one seven six ten three two one two three four five six seven eight nine ten one two three four five six seven eight nine ten one two three four five six seven eight nine ten eight five four nine one seven six ten three two -*///:~ +*/ diff --git a/containersindepth/RandomBounds.java b/containersindepth/RandomBounds.java index 9402ea9a..d945fc5e 100644 --- a/containersindepth/RandomBounds.java +++ b/containersindepth/RandomBounds.java @@ -1,4 +1,4 @@ -//: containersindepth/RandomBounds.java +// containersindepth/RandomBounds.java // ©2015 MindView LLC: see Copyright.txt // Does Math.random() produce 0.0 and 1.0? // {TimeOutDuringTesting} @@ -29,4 +29,5 @@ public class RandomBounds { usage(); } } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/containersindepth/ReadOnly.java b/containersindepth/ReadOnly.java index f07b3d49..f6be7a83 100644 --- a/containersindepth/ReadOnly.java +++ b/containersindepth/ReadOnly.java @@ -1,4 +1,4 @@ -//: containersindepth/ReadOnly.java +// containersindepth/ReadOnly.java // ©2015 MindView LLC: see Copyright.txt // Using the Collections.unmodifiable methods. import java.util.*; @@ -40,11 +40,12 @@ public class ReadOnly { Collections.unmodifiableSortedMap( new TreeMap<>(Countries.capitals(6))); } -} /* Output: +} +/* Output: [ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI] ALGERIA [BENIN, BOTSWANA, ANGOLA, BURKINA FASO, ALGERIA, BURUNDI] {BENIN=Porto-Novo, BOTSWANA=Gaberone, ANGOLA=Luanda, BURKINA FASO=Ouagadougou, ALGERIA=Algiers, BURUNDI=Bujumbura} -*///:~ +*/ diff --git a/containersindepth/References.java b/containersindepth/References.java index d4423325..c527e6f8 100644 --- a/containersindepth/References.java +++ b/containersindepth/References.java @@ -1,4 +1,4 @@ -//: containersindepth/References.java +// containersindepth/References.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates Reference objects import java.lang.ref.*; @@ -60,7 +60,8 @@ public class References { checkQueue(); } } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Just created: java.lang.ref.SoftReference@19e0bfd Just created: java.lang.ref.SoftReference@139a55 Just created: java.lang.ref.SoftReference@1db9742 @@ -82,4 +83,4 @@ Just created: java.lang.ref.PhantomReference@10bedb4 In queue: null Just created: java.lang.ref.PhantomReference@103dbd3 In queue: null -*///:~ +*/ diff --git a/containersindepth/SetPerformance.java b/containersindepth/SetPerformance.java index f4a1677b..dda4fdcf 100644 --- a/containersindepth/SetPerformance.java +++ b/containersindepth/SetPerformance.java @@ -1,4 +1,4 @@ -//: containersindepth/SetPerformance.java +// containersindepth/SetPerformance.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates performance differences in Sets. // {Args: 100 5000} Small to keep build testing short @@ -53,14 +53,15 @@ public class SetPerformance { Tester.run(new HashSet<>(), tests); Tester.run(new LinkedHashSet<>(), tests); } -} /* Output: +} +/* Output: ------------- TreeSet ------------- - size add contains iterate +size add contains iterate 100 162 90 16 ------------- HashSet ------------- - size add contains iterate +size add contains iterate 100 43 18 18 ---------- LinkedHashSet ---------- - size add contains iterate +size add contains iterate 100 49 16 10 -*///:~ +*/ diff --git a/containersindepth/SimpleHashMap.java b/containersindepth/SimpleHashMap.java index 8c25968f..74c61bed 100644 --- a/containersindepth/SimpleHashMap.java +++ b/containersindepth/SimpleHashMap.java @@ -1,17 +1,17 @@ -//: containersindepth/SimpleHashMap.java +// containersindepth/SimpleHashMap.java // ©2015 MindView LLC: see Copyright.txt // A demonstration hashed Map. import java.util.*; import com.mindviewinc.util.*; -public class SimpleHashMap extends AbstractMap { +public class SimpleHashMap extends AbstractMap { // Choose a prime number for the hash table // size, to achieve a uniform distribution: static final int SIZE = 997; // You can't have a physical array of generics, // but you can upcast to one: @SuppressWarnings("unchecked") - LinkedList>[] buckets = + LinkedList>[] buckets = new LinkedList[SIZE]; @Override public V put(K key, V value) { @@ -19,12 +19,12 @@ public class SimpleHashMap extends AbstractMap { int index = Math.abs(key.hashCode()) % SIZE; if(buckets[index] == null) buckets[index] = new LinkedList<>(); - LinkedList> bucket = buckets[index]; - MapEntry pair = new MapEntry<>(key, value); + LinkedList> bucket = buckets[index]; + MapEntry pair = new MapEntry<>(key, value); boolean found = false; - ListIterator> it = bucket.listIterator(); + ListIterator> it = bucket.listIterator(); while(it.hasNext()) { - MapEntry iPair = it.next(); + MapEntry iPair = it.next(); if(iPair.getKey().equals(key)) { oldValue = iPair.getValue(); it.set(pair); // Replace old with new @@ -40,17 +40,17 @@ public class SimpleHashMap extends AbstractMap { public V get(Object key) { int index = Math.abs(key.hashCode()) % SIZE; if(buckets[index] == null) return null; - for(MapEntry iPair : buckets[index]) + for(MapEntry iPair : buckets[index]) if(iPair.getKey().equals(key)) return iPair.getValue(); return null; } @Override - public Set> entrySet() { - Set> set= new HashSet<>(); - for(LinkedList> bucket : buckets) { + public Set> entrySet() { + Set> set= new HashSet<>(); + for(LinkedList> bucket : buckets) { if(bucket == null) continue; - for(MapEntry mpair : bucket) + for(MapEntry mpair : bucket) set.add(mpair); } return set; @@ -62,7 +62,8 @@ public class SimpleHashMap extends AbstractMap { System.out.println(m.get("ERITREA")); System.out.println(m.entrySet()); } -} /* Output: +} +/* Output: {CAPE VERDE=Praia, ANGOLA=Luanda, ETHIOPIA=Addis Ababa, BENIN=Porto-Novo, CONGO=Brazzaville, LESOTHO=Maseru, CENTRAL AFRICAN REPUBLIC=Bangui, EQUATORIAL GUINEA=Malabo, @@ -82,4 +83,4 @@ EGYPT=Cairo, BURUNDI=Bujumbura, ALGERIA=Algiers, CAMEROON=Yaounde, GHANA=Accra, KENYA=Nairobi, COTE D'IVOIR (IVORY COAST)=Yamoussoukro, BISSAU=Bissau, DJIBOUTI=Dijibouti, CHAD=N'djamena, BOTSWANA=Gaberone] -*///:~ +*/ diff --git a/containersindepth/SlowMap.java b/containersindepth/SlowMap.java index 2cc8e334..4d57306e 100644 --- a/containersindepth/SlowMap.java +++ b/containersindepth/SlowMap.java @@ -1,10 +1,10 @@ -//: containersindepth/SlowMap.java +// containersindepth/SlowMap.java // ©2015 MindView LLC: see Copyright.txt // A Map implemented with ArrayLists. import java.util.*; import com.mindviewinc.util.*; -public class SlowMap extends AbstractMap { +public class SlowMap extends AbstractMap { private List keys = new ArrayList<>(); private List values = new ArrayList<>(); @Override @@ -24,8 +24,8 @@ public class SlowMap extends AbstractMap { return values.get(keys.indexOf(key)); } @Override - public Set> entrySet() { - Set> set= new HashSet<>(); + public Set> entrySet() { + Set> set= new HashSet<>(); Iterator ki = keys.iterator(); Iterator vi = values.iterator(); while(ki.hasNext()) @@ -39,7 +39,8 @@ public class SlowMap extends AbstractMap { System.out.println(m.get("BULGARIA")); System.out.println(m.entrySet()); } -} /* Output: +} +/* Output: {ANGOLA=Luanda, CAPE VERDE=Praia, EGYPT=Cairo, BURUNDI=Bujumbura, BENIN=Porto-Novo, ALGERIA=Algiers, CAMEROON=Yaounde, CONGO=Brazzaville, CENTRAL AFRICAN @@ -53,4 +54,4 @@ CAMEROON=Yaounde, CONGO=Brazzaville, CENTRAL AFRICAN REPUBLIC=Bangui, EQUATORIAL GUINEA=Malabo, COMOROS=Moroni, DJIBOUTI=Dijibouti, BURKINA FASO=Ouagadougou, CHAD=N'djamena, BOTSWANA=Gaberone] -*///:~ +*/ diff --git a/containersindepth/SortedMapDemo.java b/containersindepth/SortedMapDemo.java index e4bb2545..36bf967b 100644 --- a/containersindepth/SortedMapDemo.java +++ b/containersindepth/SortedMapDemo.java @@ -1,4 +1,4 @@ -//: containersindepth/SortedMapDemo.java +// containersindepth/SortedMapDemo.java // ©2015 MindView LLC: see Copyright.txt // What you can do with a TreeMap. import java.util.*; @@ -26,7 +26,8 @@ public class SortedMapDemo { print(sortedMap.headMap(high)); print(sortedMap.tailMap(low)); } -} /* Output: +} +/* Output: {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0, 9=J0} 0 @@ -36,4 +37,4 @@ public class SortedMapDemo { {3=D0, 4=E0, 5=F0, 6=G0} {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0} {3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0, 9=J0} -*///:~ +*/ diff --git a/containersindepth/SortedSetDemo.java b/containersindepth/SortedSetDemo.java index c91597b1..8d0d38d1 100644 --- a/containersindepth/SortedSetDemo.java +++ b/containersindepth/SortedSetDemo.java @@ -1,4 +1,4 @@ -//: containersindepth/SortedSetDemo.java +// containersindepth/SortedSetDemo.java // ©2015 MindView LLC: see Copyright.txt // What you can do with a TreeSet. import java.util.*; @@ -27,7 +27,8 @@ public class SortedSetDemo { print(sortedSet.headSet(high)); print(sortedSet.tailSet(low)); } -} /* Output: +} +/* Output: [eight, five, four, one, seven, six, three, two] eight two @@ -36,4 +37,4 @@ two [one, seven, six, three] [eight, five, four, one, seven, six, three] [one, seven, six, three, two] -*///:~ +*/ diff --git a/containersindepth/SpringDetector.java b/containersindepth/SpringDetector.java index a5636b16..4a13c770 100644 --- a/containersindepth/SpringDetector.java +++ b/containersindepth/SpringDetector.java @@ -1,4 +1,4 @@ -//: containersindepth/SpringDetector.java +// containersindepth/SpringDetector.java // ©2015 MindView LLC: see Copyright.txt // What will the weather be? import java.lang.reflect.*; @@ -24,7 +24,8 @@ public class SpringDetector { public static void main(String[] args) throws Exception { detectSpring(Groundhog.class); } -} /* Output: +} +/* Output: map = {Groundhog #2=Early Spring!, Groundhog #5=Early Spring!, Groundhog #6=Early Spring!, Groundhog #4=Six more weeks of Winter!, Groundhog #9=Six more weeks of Winter!, @@ -34,4 +35,4 @@ Winter!, Groundhog #3=Early Spring!, Groundhog #7=Early Spring!} Looking up prediction for Groundhog #3 Key not found: Groundhog #3 -*///:~ +*/ diff --git a/containersindepth/SpringDetector2.java b/containersindepth/SpringDetector2.java index 2fb8bfbc..915c9f6d 100644 --- a/containersindepth/SpringDetector2.java +++ b/containersindepth/SpringDetector2.java @@ -1,4 +1,4 @@ -//: containersindepth/SpringDetector2.java +// containersindepth/SpringDetector2.java // ©2015 MindView LLC: see Copyright.txt // A working key. @@ -6,7 +6,8 @@ public class SpringDetector2 { public static void main(String[] args) throws Exception { SpringDetector.detectSpring(Groundhog2.class); } -} /* Output: +} +/* Output: map = {Groundhog #0=Six more weeks of Winter!, Groundhog #1=Six more weeks of Winter!, Groundhog #2=Early Spring!, Groundhog #3=Early Spring!, Groundhog #4=Six more weeks of @@ -15,4 +16,4 @@ Spring!, Groundhog #7=Early Spring!, Groundhog #8=Six more weeks of Winter!, Groundhog #9=Six more weeks of Winter!} Looking up prediction for Groundhog #3 Early Spring! -*///:~ +*/ diff --git a/containersindepth/Stacks.java b/containersindepth/Stacks.java index 69e5bc22..36e73fc0 100644 --- a/containersindepth/Stacks.java +++ b/containersindepth/Stacks.java @@ -1,4 +1,4 @@ -//: containersindepth/Stacks.java +// containersindepth/Stacks.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of Stack Class. import java.util.*; @@ -39,7 +39,8 @@ public class Stacks { printnb(stack2.pop() + " "); } -} /* Output: +} +/* Output: stack = [JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER] element 5 = JUNE @@ -53,4 +54,4 @@ FEBRUARY JANUARY stack2 = [NOVEMBER, OCTOBER, SEPTEMBER, AUGUST, JULY, JUNE, MAY, APRIL, MARCH, FEBRUARY, JANUARY] NOVEMBER OCTOBER SEPTEMBER AUGUST JULY JUNE MAY APRIL MARCH FEBRUARY JANUARY -*///:~ +*/ diff --git a/containersindepth/StringHashCode.java b/containersindepth/StringHashCode.java index 4b5131ec..cc86fde6 100644 --- a/containersindepth/StringHashCode.java +++ b/containersindepth/StringHashCode.java @@ -1,4 +1,4 @@ -//: containersindepth/StringHashCode.java +// containersindepth/StringHashCode.java // ©2015 MindView LLC: see Copyright.txt public class StringHashCode { @@ -7,7 +7,8 @@ public class StringHashCode { System.out.println(hellos[0].hashCode()); System.out.println(hellos[1].hashCode()); } -} /* Output: +} +/* Output: 69609650 69609650 -*///:~ +*/ diff --git a/containersindepth/Synchronization.java b/containersindepth/Synchronization.java index f71f2484..065bd7c3 100644 --- a/containersindepth/Synchronization.java +++ b/containersindepth/Synchronization.java @@ -1,4 +1,4 @@ -//: containersindepth/Synchronization.java +// containersindepth/Synchronization.java // ©2015 MindView LLC: see Copyright.txt // Using the Collections.synchronized methods. import java.util.*; @@ -19,4 +19,5 @@ public class Synchronization { Map sm = Collections.synchronizedSortedMap(new TreeMap<>()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/containersindepth/Test.java b/containersindepth/Test.java index c01d0d07..8d4edcbc 100644 --- a/containersindepth/Test.java +++ b/containersindepth/Test.java @@ -1,4 +1,4 @@ -//: containersindepth/Test.java +// containersindepth/Test.java // ©2015 MindView LLC: see Copyright.txt // Framework for performing timed tests of containers. @@ -8,4 +8,4 @@ public abstract class Test { // Override this method for different tests. // Returns actual number of repetitions of test. abstract int test(C container, TestParam tp); -} ///:~ +} diff --git a/containersindepth/TestParam.java b/containersindepth/TestParam.java index 60260278..10228c5b 100644 --- a/containersindepth/TestParam.java +++ b/containersindepth/TestParam.java @@ -1,4 +1,4 @@ -//: containersindepth/TestParam.java +// containersindepth/TestParam.java // ©2015 MindView LLC: see Copyright.txt // A "data transfer object." @@ -25,4 +25,4 @@ public class TestParam { vals[i] = Integer.decode(values[i]); return array(vals); } -} ///:~ +} diff --git a/containersindepth/Tester.java b/containersindepth/Tester.java index dc7288cb..1cffbb90 100644 --- a/containersindepth/Tester.java +++ b/containersindepth/Tester.java @@ -1,4 +1,4 @@ -//: containersindepth/Tester.java +// containersindepth/Tester.java // ©2015 MindView LLC: see Copyright.txt // Applies Test objects to lists of different containers. import java.util.*; @@ -79,4 +79,4 @@ public class Tester { System.out.println(); } } -} ///:~ +} diff --git a/containersindepth/ToDoList.java b/containersindepth/ToDoList.java index 5bb3f49c..9929e967 100644 --- a/containersindepth/ToDoList.java +++ b/containersindepth/ToDoList.java @@ -1,4 +1,4 @@ -//: containersindepth/ToDoList.java +// containersindepth/ToDoList.java // ©2015 MindView LLC: see Copyright.txt // A more complex use of PriorityQueue. import java.util.*; @@ -44,11 +44,12 @@ class ToDoList extends PriorityQueue { while(!toDoList.isEmpty()) System.out.println(toDoList.remove()); } -} /* Output: +} +/* Output: A1: Water lawn A2: Feed dog B1: Feed cat B7: Feed bird C3: Mow lawn C4: Empty trash -*///:~ +*/ diff --git a/containersindepth/TypesForSets.java b/containersindepth/TypesForSets.java index 558d87d4..e6159457 100644 --- a/containersindepth/TypesForSets.java +++ b/containersindepth/TypesForSets.java @@ -1,4 +1,4 @@ -//: containersindepth/TypesForSets.java +// containersindepth/TypesForSets.java // ©2015 MindView LLC: see Copyright.txt // Methods necessary to put your own type in a Set. import java.lang.reflect.InvocationTargetException; @@ -72,7 +72,8 @@ public class TypesForSets { System.out.println("Expected: " + e.getMessage()); } } -} /* Output: +} +/* Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] @@ -86,4 +87,4 @@ public class TypesForSets { 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Expected: SetType cannot be cast to java.lang.Comparable Expected: HashType cannot be cast to java.lang.Comparable -*///:~ +*/ diff --git a/containersindepth/Unsupported.java b/containersindepth/Unsupported.java index de5d9012..3aefe428 100644 --- a/containersindepth/Unsupported.java +++ b/containersindepth/Unsupported.java @@ -1,4 +1,4 @@ -//: containersindepth/Unsupported.java +// containersindepth/Unsupported.java // ©2015 MindView LLC: see Copyright.txt // Unsupported operations in Java containers. import java.util.*; @@ -44,7 +44,8 @@ public class Unsupported { test("unmodifiableList()", Collections.unmodifiableList(new ArrayList<>(list))); } -} /* Output: +} +/* Output: --- Modifiable Copy --- --- Arrays.asList() --- retainAll(): java.lang.UnsupportedOperationException @@ -61,4 +62,4 @@ add(): java.lang.UnsupportedOperationException addAll(): java.lang.UnsupportedOperationException remove(): java.lang.UnsupportedOperationException List.set(): java.lang.UnsupportedOperationException -*///:~ +*/ diff --git a/containersindepth/Utilities.java b/containersindepth/Utilities.java index fdafee90..83d10419 100644 --- a/containersindepth/Utilities.java +++ b/containersindepth/Utilities.java @@ -1,4 +1,4 @@ -//: containersindepth/Utilities.java +// containersindepth/Utilities.java // ©2015 MindView LLC: see Copyright.txt // Simple demonstrations of the Collections utilities. import java.util.*; @@ -57,7 +57,8 @@ public class Utilities { Collections.list(v.elements()); print("arrayList: " + arrayList); } -} /* Output: +} +/* Output: [one, Two, three, Four, five, six, one] 'list' disjoint (Four)?: false max: three @@ -77,4 +78,4 @@ frequency of 'pop': 7 dups: [snap, snap, snap] 'list' disjoint 'dups'?: true arrayList: [snap, snap, snap] -*///:~ +*/ diff --git a/control/BreakAndContinue.java b/control/BreakAndContinue.java index c4c199cd..0c4a096e 100644 --- a/control/BreakAndContinue.java +++ b/control/BreakAndContinue.java @@ -1,4 +1,4 @@ -//: control/BreakAndContinue.java +// control/BreakAndContinue.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates break and continue keywords. import static com.mindviewinc.util.Range.*; @@ -11,7 +11,7 @@ public class BreakAndContinue { System.out.print(i + " "); } System.out.println(); - // Using foreach: + // Using forEach: for(int i : range(100)) { if(i == 74) break; // Out of for loop if(i % 9 != 0) continue; // Next iteration @@ -28,8 +28,9 @@ public class BreakAndContinue { System.out.print(i + " "); } } -} /* Output: +} +/* Output: 0 9 18 27 36 45 54 63 72 0 9 18 27 36 45 54 63 72 10 20 30 40 -*///:~ +*/ diff --git a/control/CommaOperator.java b/control/CommaOperator.java index 79ed6d69..ede70512 100644 --- a/control/CommaOperator.java +++ b/control/CommaOperator.java @@ -1,4 +1,4 @@ -//: control/CommaOperator.java +// control/CommaOperator.java // ©2015 MindView LLC: see Copyright.txt public class CommaOperator { @@ -7,9 +7,10 @@ public class CommaOperator { System.out.println("i = " + i + " j = " + j); } } -} /* Output: +} +/* Output: i = 1 j = 11 i = 2 j = 4 i = 3 j = 6 i = 4 j = 8 -*///:~ +*/ diff --git a/control/ForEachFloat.java b/control/ForEachFloat.java index 263bcdbe..8a1d76d0 100644 --- a/control/ForEachFloat.java +++ b/control/ForEachFloat.java @@ -1,4 +1,4 @@ -//: control/ForEachFloat.java +// control/ForEachFloat.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -11,7 +11,8 @@ public class ForEachFloat { for(float x : f) System.out.println(x); } -} /* Output: +} +/* Output: 0.72711575 0.39982635 0.5309454 @@ -22,4 +23,4 @@ public class ForEachFloat { 0.4170137 0.51660204 0.73734957 -*///:~ +*/ diff --git a/control/ForEachInt.java b/control/ForEachInt.java index 4a3746e0..99c81031 100644 --- a/control/ForEachInt.java +++ b/control/ForEachInt.java @@ -1,4 +1,4 @@ -//: control/ForEachInt.java +// control/ForEachInt.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Range.*; import static com.mindviewinc.util.Print.*; @@ -15,8 +15,9 @@ public class ForEachInt { printnb(i + " "); print(); } -} /* Output: +} +/* Output: 0 1 2 3 4 5 6 7 8 9 5 6 7 8 9 5 8 11 14 17 -*///:~ +*/ diff --git a/control/ForEachString.java b/control/ForEachString.java index 08b453d4..17dc0b95 100644 --- a/control/ForEachString.java +++ b/control/ForEachString.java @@ -1,11 +1,12 @@ -//: control/ForEachString.java +// control/ForEachString.java // ©2015 MindView LLC: see Copyright.txt public class ForEachString { public static void main(String[] args) { - for(char c : "An African Swallow".toCharArray() ) + for(char c : "An African Swallow".toCharArray()) System.out.print(c + " "); } -} /* Output: +} +/* Output: A n A f r i c a n S w a l l o w -*///:~ +*/ diff --git a/control/IfElse.java b/control/IfElse.java index 99220dfc..99d26a50 100644 --- a/control/IfElse.java +++ b/control/IfElse.java @@ -1,4 +1,4 @@ -//: control/IfElse.java +// control/IfElse.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -20,8 +20,9 @@ public class IfElse { test(5, 5); print(result); } -} /* Output: +} +/* Output: 1 -1 0 -*///:~ +*/ diff --git a/control/IfElse2.java b/control/IfElse2.java index b29c705d..f73f4444 100644 --- a/control/IfElse2.java +++ b/control/IfElse2.java @@ -1,4 +1,4 @@ -//: control/IfElse2.java +// control/IfElse2.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -16,8 +16,9 @@ public class IfElse2 { print(test(5, 10)); print(test(5, 5)); } -} /* Output: +} +/* Output: 1 -1 0 -*///:~ +*/ diff --git a/control/LabeledFor.java b/control/LabeledFor.java index e1473e56..559b0c5b 100644 --- a/control/LabeledFor.java +++ b/control/LabeledFor.java @@ -1,4 +1,4 @@ -//: control/LabeledFor.java +// control/LabeledFor.java // ©2015 MindView LLC: see Copyright.txt // For loops with "labeled break" and "labeled continue." import static com.mindviewinc.util.Print.*; @@ -41,7 +41,8 @@ public class LabeledFor { } // Can't break or continue to labels here } -} /* Output: +} +/* Output: i = 0 continue inner i = 1 @@ -60,4 +61,4 @@ i = 7 continue outer i = 8 break outer -*///:~ +*/ diff --git a/control/LabeledWhile.java b/control/LabeledWhile.java index 22ebf594..b1f789b9 100644 --- a/control/LabeledWhile.java +++ b/control/LabeledWhile.java @@ -1,4 +1,4 @@ -//: control/LabeledWhile.java +// control/LabeledWhile.java // ©2015 MindView LLC: see Copyright.txt // While loops with "labeled break" and "labeled continue." import static com.mindviewinc.util.Print.*; @@ -31,7 +31,8 @@ public class LabeledWhile { } } } -} /* Output: +} +/* Output: Outer while loop i = 1 continue @@ -46,4 +47,4 @@ Outer while loop i = 6 i = 7 break outer -*///:~ +*/ diff --git a/control/ListCharacters.java b/control/ListCharacters.java index a2162fe9..9d7021e2 100644 --- a/control/ListCharacters.java +++ b/control/ListCharacters.java @@ -1,4 +1,4 @@ -//: control/ListCharacters.java +// control/ListCharacters.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates "for" loop by listing // all the lowercase ASCII letters. @@ -10,7 +10,8 @@ public class ListCharacters { System.out.println("value: " + (int)c + " character: " + c); } -} /* Output: (First 10 Lines) +} +/* Output: (First 10 Lines) value: 97 character: a value: 98 character: b value: 99 character: c @@ -22,4 +23,4 @@ value: 104 character: h value: 105 character: i value: 106 character: j ... -*///:~ +*/ diff --git a/control/StringSwitch.java b/control/StringSwitch.java index 99bab6aa..7a40f858 100644 --- a/control/StringSwitch.java +++ b/control/StringSwitch.java @@ -1,4 +1,4 @@ -//: control/StringSwitch.java +// control/StringSwitch.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -36,7 +36,8 @@ public class StringSwitch { break; } } -} /* Output: +} +/* Output: RED RED -*///:~ +*/ diff --git a/control/VowelsAndConsonants.java b/control/VowelsAndConsonants.java index be1745d1..304eb1b7 100644 --- a/control/VowelsAndConsonants.java +++ b/control/VowelsAndConsonants.java @@ -1,4 +1,4 @@ -//: control/VowelsAndConsonants.java +// control/VowelsAndConsonants.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates the switch statement. import java.util.*; @@ -24,7 +24,8 @@ public class VowelsAndConsonants { } } } -} /* Output: (First 13 Lines) +} +/* Output: (First 13 Lines) y, 121: Sometimes a vowel n, 110: consonant z, 122: consonant @@ -39,4 +40,4 @@ o, 111: vowel w, 119: Sometimes a vowel z, 122: consonant ... -*///:~ +*/ diff --git a/control/WhileTest.java b/control/WhileTest.java index 74570bbf..78b4f78f 100644 --- a/control/WhileTest.java +++ b/control/WhileTest.java @@ -1,4 +1,4 @@ -//: control/WhileTest.java +// control/WhileTest.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates the while loop. @@ -13,7 +13,8 @@ public class WhileTest { System.out.println("Inside 'while'"); System.out.println("Exited 'while'"); } -} /* Output: (First and last 5 Lines) +} +/* Output: (First and last 5 Lines) true, Inside 'while' true, Inside 'while' true, Inside 'while' @@ -25,4 +26,4 @@ true, Inside 'while' true, Inside 'while' true, Inside 'while' false, Exited 'while' -*///:~ +*/ diff --git a/debugging/SimpleDebugging.java b/debugging/SimpleDebugging.java index 6386886a..0633258f 100644 --- a/debugging/SimpleDebugging.java +++ b/debugging/SimpleDebugging.java @@ -1,4 +1,4 @@ -//: debugging/SimpleDebugging.java +// debugging/SimpleDebugging.java // ©2015 MindView LLC: see Copyright.txt // {ThrowsException} public class SimpleDebugging { @@ -19,7 +19,8 @@ public class SimpleDebugging { public static void main(String[] args) { foo1(); } -} /* Output: +} +/* Output: In foo1 In foo2 In foo3 @@ -31,4 +32,4 @@ by zero at SimpleDebugging.foo1(SimpleDebugging.java:6) at SimpleDebugging.main(SimpleDebugging.java:19) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/enums/AlarmPoints.java b/enums/AlarmPoints.java index 03b3bdfb..a97ae647 100644 --- a/enums/AlarmPoints.java +++ b/enums/AlarmPoints.java @@ -1,7 +1,7 @@ -//: enums/AlarmPoints.java +// enums/AlarmPoints.java // ©2015 MindView LLC: see Copyright.txt package enums; public enum AlarmPoints { STAIR1, STAIR2, LOBBY, OFFICE1, OFFICE2, OFFICE3, OFFICE4, BATHROOM, UTILITY, KITCHEN -} ///:~ +} diff --git a/enums/BigEnumSet.java b/enums/BigEnumSet.java index 582b16e3..09ce4ccf 100644 --- a/enums/BigEnumSet.java +++ b/enums/BigEnumSet.java @@ -1,4 +1,4 @@ -//: enums/BigEnumSet.java +// enums/BigEnumSet.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -14,7 +14,8 @@ public class BigEnumSet { EnumSet bigEnumSet = EnumSet.allOf(Big.class); System.out.println(bigEnumSet); } -} /* Output: +} +/* Output: [A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, @@ -22,4 +23,4 @@ A37, A38, A39, A40, A41, A42, A43, A44, A45, A46, A47, A48, A49, A50, A51, A52, A53, A54, A55, A56, A57, A58, A59, A60, A61, A62, A63, A64, A65, A66, A67, A68, A69, A70, A71, A72, A73, A74, A75] -*///:~ +*/ diff --git a/enums/Burrito.java b/enums/Burrito.java index 8793d6bd..1b21b00a 100644 --- a/enums/Burrito.java +++ b/enums/Burrito.java @@ -1,4 +1,4 @@ -//: enums/Burrito.java +// enums/Burrito.java // ©2015 MindView LLC: see Copyright.txt package enums; import static enums.Spiciness.*; @@ -13,8 +13,9 @@ public class Burrito { System.out.println(new Burrito(MEDIUM)); System.out.println(new Burrito(HOT)); } -} /* Output: +} +/* Output: Burrito is NOT Burrito is MEDIUM Burrito is HOT -*///:~ +*/ diff --git a/enums/CarWash.java b/enums/CarWash.java index d32a9d89..3abedb0c 100644 --- a/enums/CarWash.java +++ b/enums/CarWash.java @@ -1,4 +1,4 @@ -//: enums/CarWash.java +// enums/CarWash.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import static com.mindviewinc.util.Print.*; @@ -56,7 +56,8 @@ public class CarWash { print(wash); wash.washCar(); } -} /* Output: +} +/* Output: [BASIC, RINSE] The basic wash Rinsing @@ -65,4 +66,4 @@ The basic wash Applying hot wax Rinsing Blowing dry -*///:~ +*/ diff --git a/enums/Competitor.java b/enums/Competitor.java index 8a24bc2b..589015a4 100644 --- a/enums/Competitor.java +++ b/enums/Competitor.java @@ -1,8 +1,8 @@ -//: enums/Competitor.java +// enums/Competitor.java // ©2015 MindView LLC: see Copyright.txt // Switching one enum on another. package enums; public interface Competitor> { Outcome compete(T competitor); -} ///:~ +} diff --git a/enums/ConstantSpecificMethod.java b/enums/ConstantSpecificMethod.java index 5c638cee..73b6277e 100644 --- a/enums/ConstantSpecificMethod.java +++ b/enums/ConstantSpecificMethod.java @@ -1,4 +1,4 @@ -//: enums/ConstantSpecificMethod.java +// enums/ConstantSpecificMethod.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import java.text.*; @@ -28,7 +28,8 @@ public enum ConstantSpecificMethod { for(ConstantSpecificMethod csm : values()) System.out.println(csm.getInfo()); } -} /* Output: +} +/* Output: Jun 15, 2015 .;..;C:\Program Files (x86)\Java\xom-1.2.10.jar;C:\Program Files (x86)\Java\jdk1.8.0_45\lib\tools.jar;C:\Program Files @@ -39,4 +40,4 @@ Java\ExtractedExamples;C:\Program Files (x86)\Java\junit-4.12.jar;C:\Program Files (x86)\Java \hamcrest-core-1.3.jar; 1.8.0_45 -*///:~ +*/ diff --git a/enums/EnumClass.java b/enums/EnumClass.java index e9fb7c24..9d251c28 100644 --- a/enums/EnumClass.java +++ b/enums/EnumClass.java @@ -1,4 +1,4 @@ -//: enums/EnumClass.java +// enums/EnumClass.java // ©2015 MindView LLC: see Copyright.txt // Capabilities of the Enum class import static com.mindviewinc.util.Print.*; @@ -22,7 +22,8 @@ public class EnumClass { print(shrub); } } -} /* Output: +} +/* Output: GROUND ordinal: 0 -1 false false class Shrubbery @@ -41,4 +42,4 @@ HANGING HANGING CRAWLING GROUND -*///:~ +*/ diff --git a/enums/EnumMaps.java b/enums/EnumMaps.java index 13ea2e5b..f3f5de29 100644 --- a/enums/EnumMaps.java +++ b/enums/EnumMaps.java @@ -1,4 +1,4 @@ -//: enums/EnumMaps.java +// enums/EnumMaps.java // ©2015 MindView LLC: see Copyright.txt // Basics of EnumMaps. package enums; @@ -24,8 +24,9 @@ public class EnumMaps { print("Expected: " + e); } } -} /* Output: +} +/* Output: BATHROOM: Bathroom alert! KITCHEN: Kitchen fire! Expected: java.lang.NullPointerException -*///:~ +*/ diff --git a/enums/EnumSets.java b/enums/EnumSets.java index 8089a724..6dd5aed6 100644 --- a/enums/EnumSets.java +++ b/enums/EnumSets.java @@ -1,4 +1,4 @@ -//: enums/EnumSets.java +// enums/EnumSets.java // ©2015 MindView LLC: see Copyright.txt // Operations on EnumSets package enums; @@ -22,7 +22,8 @@ public class EnumSets { points = EnumSet.complementOf(points); print(points); } -} /* Output: +} +/* Output: [BATHROOM] [STAIR1, STAIR2, BATHROOM, KITCHEN] [LOBBY, OFFICE1, OFFICE2, OFFICE3, OFFICE4, BATHROOM, @@ -30,4 +31,4 @@ UTILITY] [LOBBY, BATHROOM, UTILITY] [STAIR1, STAIR2, OFFICE1, OFFICE2, OFFICE3, OFFICE4, KITCHEN] -*///:~ +*/ diff --git a/enums/Input.java b/enums/Input.java index f8e3a2fd..2f404bb5 100644 --- a/enums/Input.java +++ b/enums/Input.java @@ -1,4 +1,4 @@ -//: enums/Input.java +// enums/Input.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -26,4 +26,4 @@ public enum Input { // Don't include STOP: return values()[rand.nextInt(values().length - 1)]; } -} ///:~ +} diff --git a/enums/NonEnum.java b/enums/NonEnum.java index af23bac7..80bbaa37 100644 --- a/enums/NonEnum.java +++ b/enums/NonEnum.java @@ -1,4 +1,4 @@ -//: enums/NonEnum.java +// enums/NonEnum.java // ©2015 MindView LLC: see Copyright.txt public class NonEnum { @@ -11,6 +11,7 @@ public class NonEnum { System.out.println("Expected: " + e); } } -} /* Output: +} +/* Output: Expected: java.lang.NullPointerException -*///:~ +*/ diff --git a/enums/NotClasses.java b/enums/NotClasses.java index 6d6a890a..2273644f 100644 --- a/enums/NotClasses.java +++ b/enums/NotClasses.java @@ -1,4 +1,4 @@ -//: enums/NotClasses.java +// enums/NotClasses.java // ©2015 MindView LLC: see Copyright.txt // {Exec: javap -c LikeClasses} import static com.mindviewinc.util.Print.*; @@ -21,7 +21,8 @@ enum LikeClasses { public class NotClasses { // void f1(LikeClasses.WINKEN instance) {} // Nope -} /* Output: (First 12 Lines) +} +/* Output: (First 12 Lines) Compiled from "NotClasses.java" abstract class LikeClasses extends java.lang.Enum { @@ -35,4 +36,4 @@ $VALUES:[LLikeClasses; 3: invokevirtual #3 // Method "[LLikeClasses;".clone:()Ljava/lang/Object; ... -*///:~ +*/ diff --git a/enums/Outcome.java b/enums/Outcome.java index ed483344..45e82340 100644 --- a/enums/Outcome.java +++ b/enums/Outcome.java @@ -1,4 +1,4 @@ -//: enums/Outcome.java +// enums/Outcome.java // ©2015 MindView LLC: see Copyright.txt package enums; -public enum Outcome { WIN, LOSE, DRAW } ///:~ +public enum Outcome { WIN, LOSE, DRAW } diff --git a/enums/OverrideConstantSpecific.java b/enums/OverrideConstantSpecific.java index 0bf45e06..d292571c 100644 --- a/enums/OverrideConstantSpecific.java +++ b/enums/OverrideConstantSpecific.java @@ -1,4 +1,4 @@ -//: enums/OverrideConstantSpecific.java +// enums/OverrideConstantSpecific.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -15,8 +15,9 @@ public enum OverrideConstantSpecific { ocs.f(); } } -} /* Output: +} +/* Output: NUT: default behavior BOLT: default behavior WASHER: Overridden method -*///:~ +*/ diff --git a/enums/OzWitch.java b/enums/OzWitch.java index 3082ff23..1d113071 100644 --- a/enums/OzWitch.java +++ b/enums/OzWitch.java @@ -1,4 +1,4 @@ -//: enums/OzWitch.java +// enums/OzWitch.java // ©2015 MindView LLC: see Copyright.txt // The witches in the land of Oz. import static com.mindviewinc.util.Print.*; @@ -20,10 +20,11 @@ public enum OzWitch { for(OzWitch witch : OzWitch.values()) print(witch + ": " + witch.getDescription()); } -} /* Output: +} +/* Output: WEST: Miss Gulch, aka the Wicked Witch of the West NORTH: Glinda, the Good Witch of the North EAST: Wicked Witch of the East, wearer of the Ruby Slippers, crushed by Dorothy's house SOUTH: Good by inference, but missing -*///:~ +*/ diff --git a/enums/PostOffice.java b/enums/PostOffice.java index 19215c06..cec10a67 100644 --- a/enums/PostOffice.java +++ b/enums/PostOffice.java @@ -1,4 +1,4 @@ -//: enums/PostOffice.java +// enums/PostOffice.java // ©2015 MindView LLC: see Copyright.txt // Modeling a post office. import java.util.*; @@ -128,7 +128,8 @@ public class PostOffice { print("*****"); } } -} /* Output: +} +/* Output: Mail 0, General Delivery: NO2, Address Scanability: UNSCANNABLE, Address Readability: YES3, Address Address: OK1, Return address: OK1 @@ -179,4 +180,4 @@ UNSCANNABLE, Address Readability: YES2, Address Address: OK1, Return address: OK4 Delivering Mail 9 normally ***** -*///:~ +*/ diff --git a/enums/RandomTest.java b/enums/RandomTest.java index bb7b0d87..7abd729e 100644 --- a/enums/RandomTest.java +++ b/enums/RandomTest.java @@ -1,4 +1,4 @@ -//: enums/RandomTest.java +// enums/RandomTest.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -10,8 +10,9 @@ public class RandomTest { for(int i = 0; i < 20; i++) System.out.print(Enums.random(Activity.class) + " "); } -} /* Output: +} +/* Output: STANDING FLYING RUNNING STANDING RUNNING STANDING LYING DODGING SITTING RUNNING HOPPING HOPPING HOPPING RUNNING STANDING LYING FALLING RUNNING FLYING LYING -*///:~ +*/ diff --git a/enums/Reflection.java b/enums/Reflection.java index f9c53b86..f782acfe 100644 --- a/enums/Reflection.java +++ b/enums/Reflection.java @@ -1,4 +1,4 @@ -//: enums/Reflection.java +// enums/Reflection.java // ©2015 MindView LLC: see Copyright.txt // Analyzing enums using reflection. import java.lang.reflect.*; @@ -33,7 +33,8 @@ public class Reflection { // Decompile the code for the enum: OSExecute.command("javap Explore"); } -} /* Output: +} +/* Output: ----- Analyzing class Explore ----- Interfaces: Base: class java.lang.Enum @@ -59,4 +60,4 @@ final class Explore extends java.lang.Enum { public static Explore valueOf(java.lang.String); static {}; } -*///:~ +*/ diff --git a/enums/RoShamBo.java b/enums/RoShamBo.java index d6f04f55..e5f48e17 100644 --- a/enums/RoShamBo.java +++ b/enums/RoShamBo.java @@ -1,4 +1,4 @@ -//: enums/RoShamBo.java +// enums/RoShamBo.java // ©2015 MindView LLC: see Copyright.txt // Common tools for RoShamBo examples. package enums; @@ -16,4 +16,4 @@ public class RoShamBo { match( Enums.random(rsbClass),Enums.random(rsbClass)); } -} ///:~ +} diff --git a/enums/RoShamBo1.java b/enums/RoShamBo1.java index a204d34a..34099062 100644 --- a/enums/RoShamBo1.java +++ b/enums/RoShamBo1.java @@ -1,4 +1,4 @@ -//: enums/RoShamBo1.java +// enums/RoShamBo1.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of multiple dispatching. package enums; @@ -70,7 +70,8 @@ public class RoShamBo1 { for(int i = 0; i < SIZE; i++) match(newItem(), newItem()); } -} /* Output: +} +/* Output: Rock vs. Rock: DRAW Paper vs. Rock: WIN Paper vs. Rock: WIN @@ -91,4 +92,4 @@ Paper vs. Scissors: LOSE Paper vs. Scissors: LOSE Paper vs. Scissors: LOSE Paper vs. Scissors: LOSE -*///:~ +*/ diff --git a/enums/RoShamBo2.java b/enums/RoShamBo2.java index 250237e6..6db2b6a9 100644 --- a/enums/RoShamBo2.java +++ b/enums/RoShamBo2.java @@ -1,4 +1,4 @@ -//: enums/RoShamBo2.java +// enums/RoShamBo2.java // ©2015 MindView LLC: see Copyright.txt // Switching one enum on another. package enums; @@ -26,7 +26,8 @@ public enum RoShamBo2 implements Competitor { public static void main(String[] args) { RoShamBo.play(RoShamBo2.class, 20); } -} /* Output: +} +/* Output: ROCK vs. ROCK: DRAW SCISSORS vs. ROCK: LOSE SCISSORS vs. ROCK: LOSE @@ -47,4 +48,4 @@ SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN -*///:~ +*/ diff --git a/enums/RoShamBo3.java b/enums/RoShamBo3.java index 6871621c..66bb891a 100644 --- a/enums/RoShamBo3.java +++ b/enums/RoShamBo3.java @@ -1,4 +1,4 @@ -//: enums/RoShamBo3.java +// enums/RoShamBo3.java // ©2015 MindView LLC: see Copyright.txt // Using constant-specific methods. package enums; @@ -43,7 +43,8 @@ public enum RoShamBo3 implements Competitor { public static void main(String[] args) { RoShamBo.play(RoShamBo3.class, 20); } -} /* Output: +} +/* Output: ROCK vs. ROCK: DRAW SCISSORS vs. ROCK: LOSE SCISSORS vs. ROCK: LOSE @@ -64,4 +65,4 @@ SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN -*///:~ +*/ diff --git a/enums/RoShamBo4.java b/enums/RoShamBo4.java index d69a9b0d..a8adb698 100644 --- a/enums/RoShamBo4.java +++ b/enums/RoShamBo4.java @@ -1,4 +1,4 @@ -//: enums/RoShamBo4.java +// enums/RoShamBo4.java // ©2015 MindView LLC: see Copyright.txt package enums; @@ -29,7 +29,8 @@ public enum RoShamBo4 implements Competitor { public static void main(String[] args) { RoShamBo.play(RoShamBo4.class, 20); } -} /* Output: +} +/* Output: PAPER vs. PAPER: DRAW SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN @@ -50,4 +51,4 @@ SCISSORS vs. ROCK: LOSE SCISSORS vs. ROCK: LOSE SCISSORS vs. ROCK: LOSE SCISSORS vs. ROCK: LOSE -*///:~ +*/ diff --git a/enums/RoShamBo5.java b/enums/RoShamBo5.java index 48268830..310a9a2c 100644 --- a/enums/RoShamBo5.java +++ b/enums/RoShamBo5.java @@ -1,4 +1,4 @@ -//: enums/RoShamBo5.java +// enums/RoShamBo5.java // ©2015 MindView LLC: see Copyright.txt // Multiple dispatching using an EnumMap of EnumMaps. package enums; @@ -31,7 +31,8 @@ enum RoShamBo5 implements Competitor { public static void main(String[] args) { RoShamBo.play(RoShamBo5.class, 20); } -} /* Output: +} +/* Output: ROCK vs. ROCK: DRAW SCISSORS vs. ROCK: LOSE SCISSORS vs. ROCK: LOSE @@ -52,4 +53,4 @@ SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN -*///:~ +*/ diff --git a/enums/RoShamBo6.java b/enums/RoShamBo6.java index c337a7bf..d8b1b15a 100644 --- a/enums/RoShamBo6.java +++ b/enums/RoShamBo6.java @@ -1,4 +1,4 @@ -//: enums/RoShamBo6.java +// enums/RoShamBo6.java // ©2015 MindView LLC: see Copyright.txt // Enums using "tables" instead of multiple dispatch. package enums; @@ -18,7 +18,8 @@ enum RoShamBo6 implements Competitor { public static void main(String[] args) { RoShamBo.play(RoShamBo6.class, 20); } -} /* Output: +} +/* Output: ROCK vs. ROCK: DRAW SCISSORS vs. ROCK: LOSE SCISSORS vs. ROCK: LOSE @@ -39,4 +40,4 @@ SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN SCISSORS vs. PAPER: WIN -*///:~ +*/ diff --git a/enums/SecurityCategory.java b/enums/SecurityCategory.java index aefed8ff..c221e292 100644 --- a/enums/SecurityCategory.java +++ b/enums/SecurityCategory.java @@ -1,4 +1,4 @@ -//: enums/SecurityCategory.java +// enums/SecurityCategory.java // ©2015 MindView LLC: see Copyright.txt // More succinct subcategorization of enums. import com.mindviewinc.util.*; @@ -24,7 +24,8 @@ enum SecurityCategory { category.randomSelection()); } } -} /* Output: +} +/* Output: BOND: MUNICIPAL BOND: MUNICIPAL STOCK: MARGIN @@ -35,4 +36,4 @@ STOCK: LONG STOCK: LONG BOND: MUNICIPAL BOND: JUNK -*///:~ +*/ diff --git a/enums/SpaceShip.java b/enums/SpaceShip.java index 64f12b8a..77229401 100644 --- a/enums/SpaceShip.java +++ b/enums/SpaceShip.java @@ -1,4 +1,4 @@ -//: enums/SpaceShip.java +// enums/SpaceShip.java // ©2015 MindView LLC: see Copyright.txt public enum SpaceShip { SCOUT, CARGO, TRANSPORT, CRUISER, BATTLESHIP, MOTHERSHIP; @@ -13,11 +13,12 @@ public enum SpaceShip { System.out.println(s); } } -} /* Output: +} +/* Output: Scout Cargo Transport Cruiser Battleship Mothership -*///:~ +*/ diff --git a/enums/Spiciness.java b/enums/Spiciness.java index 7a60201a..0200753f 100644 --- a/enums/Spiciness.java +++ b/enums/Spiciness.java @@ -1,7 +1,7 @@ -//: enums/Spiciness.java +// enums/Spiciness.java // ©2015 MindView LLC: see Copyright.txt package enums; public enum Spiciness { NOT, MILD, MEDIUM, HOT, FLAMING -} ///:~ +} diff --git a/enums/TrafficLight.java b/enums/TrafficLight.java index b11577c5..51f363f1 100644 --- a/enums/TrafficLight.java +++ b/enums/TrafficLight.java @@ -1,4 +1,4 @@ -//: enums/TrafficLight.java +// enums/TrafficLight.java // ©2015 MindView LLC: see Copyright.txt // Enums in switch statements. import static com.mindviewinc.util.Print.*; @@ -31,7 +31,8 @@ public class TrafficLight { t.change(); } } -} /* Output: +} +/* Output: The traffic light is RED The traffic light is GREEN The traffic light is YELLOW @@ -39,4 +40,4 @@ The traffic light is RED The traffic light is GREEN The traffic light is YELLOW The traffic light is RED -*///:~ +*/ diff --git a/enums/UpcastEnum.java b/enums/UpcastEnum.java index fada1708..fb9cd1d4 100644 --- a/enums/UpcastEnum.java +++ b/enums/UpcastEnum.java @@ -1,4 +1,4 @@ -//: enums/UpcastEnum.java +// enums/UpcastEnum.java // ©2015 MindView LLC: see Copyright.txt // No values() method if you upcast an enum @@ -12,7 +12,8 @@ public class UpcastEnum { for(Enum en : e.getClass().getEnumConstants()) System.out.println(en); } -} /* Output: +} +/* Output: HITHER YON -*///:~ +*/ diff --git a/enums/VendingMachine.java b/enums/VendingMachine.java index b2081049..a41f7944 100644 --- a/enums/VendingMachine.java +++ b/enums/VendingMachine.java @@ -1,4 +1,4 @@ -//: enums/VendingMachine.java +// enums/VendingMachine.java // ©2015 MindView LLC: see Copyright.txt // {Args: VendingMachineInput.txt} import java.util.*; @@ -87,7 +87,7 @@ public class VendingMachine { } }, TERMINAL {@Override - void output() { print("Halted"); } }; +void output() { print("Halted"); } }; private boolean isTransient = false; State() {} State(StateDuration trans) { isTransient = true; } @@ -136,7 +136,8 @@ class FileInputGenerator implements Generator { return null; return Enum.valueOf(Input.class, input.next().trim()); } -} /* Output: +} +/* Output: 25 50 Insufficient money for CHIPS @@ -162,4 +163,4 @@ Insufficient money for SODA Your change: 75 0 Halted -*///:~ +*/ diff --git a/enums/VendingMachineInput.txt b/enums/VendingMachineInput.txt index 7dd1354e..b39554f0 100644 --- a/enums/VendingMachineInput.txt +++ b/enums/VendingMachineInput.txt @@ -1,4 +1,4 @@ -//: enums/VendingMachineInput.txt +// enums/VendingMachineInput.txt QUARTER; QUARTER; QUARTER; CHIPS; DOLLAR; DOLLAR; TOOTHPASTE; QUARTER; DIME; ABORT_TRANSACTION; @@ -6,4 +6,3 @@ QUARTER; DIME; SODA; QUARTER; DIME; NICKEL; SODA; ABORT_TRANSACTION; STOP; -///:~ diff --git a/enums/cartoons/EnumImplementation.java b/enums/cartoons/EnumImplementation.java index 915fde29..cdfa83d9 100644 --- a/enums/cartoons/EnumImplementation.java +++ b/enums/cartoons/EnumImplementation.java @@ -1,4 +1,4 @@ -//: enums/cartoons/EnumImplementation.java +// enums/cartoons/EnumImplementation.java // ©2015 MindView LLC: see Copyright.txt // An enum can implement an interface package enums.cartoons; @@ -25,7 +25,8 @@ public class EnumImplementation { for(int i = 0; i < 10; i++) printNext(cc); } -} /* Output: +} +/* Output: BOB, PUNCHY, BOB, SPANKY, NUTTY, PUNCHY, SLAPPY, NUTTY, NUTTY, SLAPPY, -*///:~ +*/ diff --git a/enums/menu/Course.java b/enums/menu/Course.java index 1eb7c9c8..4498f008 100644 --- a/enums/menu/Course.java +++ b/enums/menu/Course.java @@ -1,4 +1,4 @@ -//: enums/menu/Course.java +// enums/menu/Course.java // ©2015 MindView LLC: see Copyright.txt package enums.menu; import com.mindviewinc.util.*; @@ -15,4 +15,4 @@ public enum Course { public Food randomSelection() { return Enums.random(values); } -} ///:~ +} diff --git a/enums/menu/Food.java b/enums/menu/Food.java index cf961fac..ffe5e4d2 100644 --- a/enums/menu/Food.java +++ b/enums/menu/Food.java @@ -1,4 +1,4 @@ -//: enums/menu/Food.java +// enums/menu/Food.java // ©2015 MindView LLC: see Copyright.txt // Subcategorization of enums within interfaces. package enums.menu; @@ -19,4 +19,4 @@ public interface Food { BLACK_COFFEE, DECAF_COFFEE, ESPRESSO, LATTE, CAPPUCCINO, TEA, HERB_TEA; } -} ///:~ +} diff --git a/enums/menu/Meal.java b/enums/menu/Meal.java index 1dee9b81..9b0167bc 100644 --- a/enums/menu/Meal.java +++ b/enums/menu/Meal.java @@ -1,4 +1,4 @@ -//: enums/menu/Meal.java +// enums/menu/Meal.java // ©2015 MindView LLC: see Copyright.txt package enums.menu; @@ -12,7 +12,8 @@ public class Meal { System.out.println("---"); } } -} /* Output: +} +/* Output: SPRING_ROLLS VINDALOO FRUIT @@ -38,4 +39,4 @@ BURRITO TIRAMISU ESPRESSO --- -*///:~ +*/ diff --git a/enums/menu/Meal2.java b/enums/menu/Meal2.java index aeaaf7c6..61dd7511 100644 --- a/enums/menu/Meal2.java +++ b/enums/menu/Meal2.java @@ -1,4 +1,4 @@ -//: enums/menu/Meal2.java +// enums/menu/Meal2.java // ©2015 MindView LLC: see Copyright.txt package enums.menu; import com.mindviewinc.util.*; @@ -41,7 +41,8 @@ public enum Meal2 { System.out.println("---"); } } -} /* Output: +} +/* Output: SPRING_ROLLS VINDALOO FRUIT @@ -67,4 +68,4 @@ BURRITO TIRAMISU ESPRESSO --- -*///:~ +*/ diff --git a/enums/menu/TypeOfFood.java b/enums/menu/TypeOfFood.java index 3620b2d4..976b2564 100644 --- a/enums/menu/TypeOfFood.java +++ b/enums/menu/TypeOfFood.java @@ -1,4 +1,4 @@ -//: enums/menu/TypeOfFood.java +// enums/menu/TypeOfFood.java // ©2015 MindView LLC: see Copyright.txt package enums.menu; import static enums.menu.Food.*; @@ -10,4 +10,5 @@ public class TypeOfFood { food = Dessert.GELATO; food = Coffee.CAPPUCCINO; } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/exceptions/AlwaysFinally.java b/exceptions/AlwaysFinally.java index d3f1db6d..ea8ab367 100644 --- a/exceptions/AlwaysFinally.java +++ b/exceptions/AlwaysFinally.java @@ -1,4 +1,4 @@ -//: exceptions/AlwaysFinally.java +// exceptions/AlwaysFinally.java // ©2015 MindView LLC: see Copyright.txt // Finally is always executed. import static com.mindviewinc.util.Print.*; @@ -22,10 +22,11 @@ public class AlwaysFinally { System.out.println("finally in 1st try block"); } } -} /* Output: +} +/* Output: Entering first try block Entering second try block finally in 2nd try block Caught FourException in 1st try block finally in 1st try block -*///:~ +*/ diff --git a/exceptions/Cleanup.java b/exceptions/Cleanup.java index a84d9ecd..3d66587b 100644 --- a/exceptions/Cleanup.java +++ b/exceptions/Cleanup.java @@ -1,4 +1,4 @@ -//: exceptions/Cleanup.java +// exceptions/Cleanup.java // ©2015 MindView LLC: see Copyright.txt // Guaranteeing proper cleanup of a resource. @@ -21,6 +21,7 @@ public class Cleanup { System.out.println("InputFile construction failed"); } } -} /* Output: +} +/* Output: dispose() successful -*///:~ +*/ diff --git a/exceptions/CleanupIdiom.java b/exceptions/CleanupIdiom.java index 414a78ec..18e8a8a0 100644 --- a/exceptions/CleanupIdiom.java +++ b/exceptions/CleanupIdiom.java @@ -1,4 +1,4 @@ -//: exceptions/CleanupIdiom.java +// exceptions/CleanupIdiom.java // ©2015 MindView LLC: see Copyright.txt // Each disposable object must be followed by a try-finally @@ -58,10 +58,11 @@ public class CleanupIdiom { System.out.println(e); } } -} /* Output: +} +/* Output: NeedsCleanup 1 disposed NeedsCleanup 3 disposed NeedsCleanup 2 disposed NeedsCleanup 5 disposed NeedsCleanup 4 disposed -*///:~ +*/ diff --git a/exceptions/DynamicFields.java b/exceptions/DynamicFields.java index e6999c86..e3d36307 100644 --- a/exceptions/DynamicFields.java +++ b/exceptions/DynamicFields.java @@ -1,4 +1,4 @@ -//: exceptions/DynamicFields.java +// exceptions/DynamicFields.java // ©2015 MindView LLC: see Copyright.txt // A Class that dynamically adds fields to itself. // Demonstrates exception chaining. @@ -98,7 +98,8 @@ public class DynamicFields { e.printStackTrace(System.out); } } -} /* Output: +} +/* Output: null: null null: null null: null @@ -116,4 +117,4 @@ DynamicFieldsException Caused by: java.lang.NullPointerException at DynamicFields.setField(DynamicFields.java:66) ... 1 more -*///:~ +*/ diff --git a/exceptions/ExceptionMethods.java b/exceptions/ExceptionMethods.java index b2ec0545..1ff2adea 100644 --- a/exceptions/ExceptionMethods.java +++ b/exceptions/ExceptionMethods.java @@ -1,4 +1,4 @@ -//: exceptions/ExceptionMethods.java +// exceptions/ExceptionMethods.java // ©2015 MindView LLC: see Copyright.txt // Demonstrating the Exception Methods. import static com.mindviewinc.util.Print.*; @@ -17,7 +17,8 @@ public class ExceptionMethods { e.printStackTrace(System.out); } } -} /* Output: +} +/* Output: Caught Exception getMessage():My Exception getLocalizedMessage():My Exception @@ -25,4 +26,4 @@ toString():java.lang.Exception: My Exception printStackTrace(): java.lang.Exception: My Exception at ExceptionMethods.main(ExceptionMethods.java:8) -*///:~ +*/ diff --git a/exceptions/ExceptionSilencer.java b/exceptions/ExceptionSilencer.java index b1fda80e..20218a97 100644 --- a/exceptions/ExceptionSilencer.java +++ b/exceptions/ExceptionSilencer.java @@ -1,4 +1,4 @@ -//: exceptions/ExceptionSilencer.java +// exceptions/ExceptionSilencer.java // ©2015 MindView LLC: see Copyright.txt public class ExceptionSilencer { @@ -11,4 +11,5 @@ public class ExceptionSilencer { return; } } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/exceptions/ExtraFeatures.java b/exceptions/ExtraFeatures.java index e2c4b0d1..2f1dfebd 100644 --- a/exceptions/ExtraFeatures.java +++ b/exceptions/ExtraFeatures.java @@ -1,4 +1,4 @@ -//: exceptions/ExtraFeatures.java +// exceptions/ExtraFeatures.java // ©2015 MindView LLC: see Copyright.txt // Further embellishment of exception classes. import static com.mindviewinc.util.Print.*; @@ -49,7 +49,8 @@ public class ExtraFeatures { System.out.println("e.val() = " + e.val()); } } -} /* Output: +} +/* Output: Throwing MyException2 from f() MyException2: Detail Message: 0 null at ExtraFeatures.f(ExtraFeatures.java:23) @@ -63,4 +64,4 @@ MyException2: Detail Message: 47 Originated in h() at ExtraFeatures.h(ExtraFeatures.java:31) at ExtraFeatures.main(ExtraFeatures.java:45) e.val() = 47 -*///:~ +*/ diff --git a/exceptions/FinallyWorks.java b/exceptions/FinallyWorks.java index 459d075a..9716d0ee 100644 --- a/exceptions/FinallyWorks.java +++ b/exceptions/FinallyWorks.java @@ -1,4 +1,4 @@ -//: exceptions/FinallyWorks.java +// exceptions/FinallyWorks.java // ©2015 MindView LLC: see Copyright.txt // The finally clause is always executed. @@ -21,9 +21,10 @@ public class FinallyWorks { } } } -} /* Output: +} +/* Output: ThreeException In finally clause No exception In finally clause -*///:~ +*/ diff --git a/exceptions/FullConstructors.java b/exceptions/FullConstructors.java index 267f2f23..fe39e103 100644 --- a/exceptions/FullConstructors.java +++ b/exceptions/FullConstructors.java @@ -1,4 +1,4 @@ -//: exceptions/FullConstructors.java +// exceptions/FullConstructors.java // ©2015 MindView LLC: see Copyright.txt class MyException extends Exception { @@ -27,7 +27,8 @@ public class FullConstructors { e.printStackTrace(System.out); } } -} /* Output: +} +/* Output: Throwing MyException from f() MyException at FullConstructors.f(FullConstructors.java:11) @@ -36,4 +37,4 @@ Throwing MyException from g() MyException: Originated in g() at FullConstructors.g(FullConstructors.java:15) at FullConstructors.main(FullConstructors.java:24) -*///:~ +*/ diff --git a/exceptions/Human.java b/exceptions/Human.java index e725c968..4134e036 100644 --- a/exceptions/Human.java +++ b/exceptions/Human.java @@ -1,4 +1,4 @@ -//: exceptions/Human.java +// exceptions/Human.java // ©2015 MindView LLC: see Copyright.txt // Catching exception hierarchies. @@ -22,7 +22,8 @@ public class Human { System.out.println("Caught Annoyance"); } } -} /* Output: +} +/* Output: Caught Sneeze Caught Annoyance -*///:~ +*/ diff --git a/exceptions/InheritingExceptions.java b/exceptions/InheritingExceptions.java index 94284d50..8df1e548 100644 --- a/exceptions/InheritingExceptions.java +++ b/exceptions/InheritingExceptions.java @@ -1,4 +1,4 @@ -//: exceptions/InheritingExceptions.java +// exceptions/InheritingExceptions.java // ©2015 MindView LLC: see Copyright.txt // Creating your own exceptions. @@ -17,7 +17,8 @@ public class InheritingExceptions { System.out.println("Caught it!"); } } -} /* Output: +} +/* Output: Throw SimpleException from f() Caught it! -*///:~ +*/ diff --git a/exceptions/InputFile.java b/exceptions/InputFile.java index 911fccfd..4ec67612 100644 --- a/exceptions/InputFile.java +++ b/exceptions/InputFile.java @@ -1,4 +1,4 @@ -//: exceptions/InputFile.java +// exceptions/InputFile.java // ©2015 MindView LLC: see Copyright.txt // Paying attention to exceptions in constructors. import java.io.*; @@ -42,4 +42,4 @@ public class InputFile { throw new RuntimeException("in.close() failed"); } } -} ///:~ +} diff --git a/exceptions/LoggingExceptions.java b/exceptions/LoggingExceptions.java index 9a3858fb..50be490f 100644 --- a/exceptions/LoggingExceptions.java +++ b/exceptions/LoggingExceptions.java @@ -1,4 +1,4 @@ -//: exceptions/LoggingExceptions.java +// exceptions/LoggingExceptions.java // ©2015 MindView LLC: see Copyright.txt // An exception that reports through a Logger. import java.util.logging.*; @@ -27,7 +27,8 @@ public class LoggingExceptions { System.err.println("Caught " + e); } } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:40 PM LoggingException SEVERE: LoggingException @@ -39,4 +40,4 @@ SEVERE: LoggingException at LoggingExceptions.main(LoggingExceptions.java:24) Caught LoggingException -*///:~ +*/ diff --git a/exceptions/LoggingExceptions2.java b/exceptions/LoggingExceptions2.java index 1ee1ee07..b5b358a9 100644 --- a/exceptions/LoggingExceptions2.java +++ b/exceptions/LoggingExceptions2.java @@ -1,4 +1,4 @@ -//: exceptions/LoggingExceptions2.java +// exceptions/LoggingExceptions2.java // ©2015 MindView LLC: see Copyright.txt // Logging caught exceptions. import java.util.logging.*; @@ -19,10 +19,11 @@ public class LoggingExceptions2 { logException(e); } } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:40 PM LoggingExceptions2 logException SEVERE: java.lang.NullPointerException at LoggingExceptions2.main(LoggingExceptions2.java:16) -*///:~ +*/ diff --git a/exceptions/LostMessage.java b/exceptions/LostMessage.java index fd254551..4a98a7e3 100644 --- a/exceptions/LostMessage.java +++ b/exceptions/LostMessage.java @@ -1,4 +1,4 @@ -//: exceptions/LostMessage.java +// exceptions/LostMessage.java // ©2015 MindView LLC: see Copyright.txt // How an exception can be lost. @@ -36,6 +36,7 @@ public class LostMessage { System.out.println(e); } } -} /* Output: +} +/* Output: A trivial exception -*///:~ +*/ diff --git a/exceptions/MainException.java b/exceptions/MainException.java index e367a15e..7dc7ad11 100644 --- a/exceptions/MainException.java +++ b/exceptions/MainException.java @@ -1,4 +1,4 @@ -//: exceptions/MainException.java +// exceptions/MainException.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -12,4 +12,5 @@ public class MainException { // Close the file: file.close(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/exceptions/MultipleReturns.java b/exceptions/MultipleReturns.java index ec1d432c..24ead358 100644 --- a/exceptions/MultipleReturns.java +++ b/exceptions/MultipleReturns.java @@ -1,4 +1,4 @@ -//: exceptions/MultipleReturns.java +// exceptions/MultipleReturns.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -22,7 +22,8 @@ public class MultipleReturns { for(int i = 1; i <= 4; i++) f(i); } -} /* Output: +} +/* Output: Initialization that requires cleanup Point 1 Performing cleanup @@ -41,4 +42,4 @@ Point 2 Point 3 End Performing cleanup -*///:~ +*/ diff --git a/exceptions/NeverCaught.java b/exceptions/NeverCaught.java index b9969e8f..13f6e6ca 100644 --- a/exceptions/NeverCaught.java +++ b/exceptions/NeverCaught.java @@ -1,4 +1,4 @@ -//: exceptions/NeverCaught.java +// exceptions/NeverCaught.java // ©2015 MindView LLC: see Copyright.txt // Ignoring RuntimeExceptions. // {ThrowsException} @@ -13,7 +13,8 @@ public class NeverCaught { public static void main(String[] args) { g(); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Exception in thread "main" java.lang.RuntimeException: From f() @@ -21,4 +22,4 @@ f() at NeverCaught.g(NeverCaught.java:10) at NeverCaught.main(NeverCaught.java:13) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/exceptions/OnOffException1.java b/exceptions/OnOffException1.java index 4eecb13c..4b455c83 100644 --- a/exceptions/OnOffException1.java +++ b/exceptions/OnOffException1.java @@ -1,3 +1,3 @@ -//: exceptions/OnOffException1.java +// exceptions/OnOffException1.java // ©2015 MindView LLC: see Copyright.txt -public class OnOffException1 extends Exception {} ///:~ +public class OnOffException1 extends Exception {} diff --git a/exceptions/OnOffException2.java b/exceptions/OnOffException2.java index 97e6f2e8..62af6f0c 100644 --- a/exceptions/OnOffException2.java +++ b/exceptions/OnOffException2.java @@ -1,3 +1,3 @@ -//: exceptions/OnOffException2.java +// exceptions/OnOffException2.java // ©2015 MindView LLC: see Copyright.txt -public class OnOffException2 extends Exception {} ///:~ +public class OnOffException2 extends Exception {} diff --git a/exceptions/OnOffSwitch.java b/exceptions/OnOffSwitch.java index da72c9cd..680b79e4 100644 --- a/exceptions/OnOffSwitch.java +++ b/exceptions/OnOffSwitch.java @@ -1,11 +1,11 @@ -//: exceptions/OnOffSwitch.java +// exceptions/OnOffSwitch.java // ©2015 MindView LLC: see Copyright.txt // Why use finally? public class OnOffSwitch { private static Switch sw = new Switch(); public static void f() - throws OnOffException1,OnOffException2 {} + throws OnOffException1, OnOffException2 {} public static void main(String[] args) { try { sw.on(); @@ -20,7 +20,8 @@ public class OnOffSwitch { sw.off(); } } -} /* Output: +} +/* Output: on off -*///:~ +*/ diff --git a/exceptions/RethrowNew.java b/exceptions/RethrowNew.java index aa7e45fb..70fcb4aa 100644 --- a/exceptions/RethrowNew.java +++ b/exceptions/RethrowNew.java @@ -1,4 +1,4 @@ -//: exceptions/RethrowNew.java +// exceptions/RethrowNew.java // ©2015 MindView LLC: see Copyright.txt // Rethrow a different object from the one that was caught. @@ -31,7 +31,8 @@ public class RethrowNew { e.printStackTrace(System.out); } } -} /* Output: +} +/* Output: originating the exception in f() Caught in inner try, e.printStackTrace() OneException: thrown from f() @@ -40,4 +41,4 @@ OneException: thrown from f() Caught in outer try, e.printStackTrace() TwoException: from inner try at RethrowNew.main(RethrowNew.java:25) -*///:~ +*/ diff --git a/exceptions/Rethrowing.java b/exceptions/Rethrowing.java index 62c3666a..b151e51f 100644 --- a/exceptions/Rethrowing.java +++ b/exceptions/Rethrowing.java @@ -1,4 +1,4 @@ -//: exceptions/Rethrowing.java +// exceptions/Rethrowing.java // ©2015 MindView LLC: see Copyright.txt // Demonstrating fillInStackTrace() @@ -11,7 +11,7 @@ public class Rethrowing { try { f(); } catch(Exception e) { - System.out.println("Inside g(),e.printStackTrace()"); + System.out.println("Inside g(), e.printStackTrace()"); e.printStackTrace(System.out); throw e; } @@ -20,7 +20,7 @@ public class Rethrowing { try { f(); } catch(Exception e) { - System.out.println("Inside h(),e.printStackTrace()"); + System.out.println("Inside h(), e.printStackTrace()"); e.printStackTrace(System.out); throw (Exception)e.fillInStackTrace(); } @@ -39,9 +39,10 @@ public class Rethrowing { e.printStackTrace(System.out); } } -} /* Output: +} +/* Output: originating the exception in f() -Inside g(),e.printStackTrace() +Inside g(), e.printStackTrace() java.lang.Exception: thrown from f() at Rethrowing.f(Rethrowing.java:7) at Rethrowing.g(Rethrowing.java:11) @@ -52,7 +53,7 @@ java.lang.Exception: thrown from f() at Rethrowing.g(Rethrowing.java:11) at Rethrowing.main(Rethrowing.java:29) originating the exception in f() -Inside h(),e.printStackTrace() +Inside h(), e.printStackTrace() java.lang.Exception: thrown from f() at Rethrowing.f(Rethrowing.java:7) at Rethrowing.h(Rethrowing.java:20) @@ -61,4 +62,4 @@ main: printStackTrace() java.lang.Exception: thrown from f() at Rethrowing.h(Rethrowing.java:24) at Rethrowing.main(Rethrowing.java:35) -*///:~ +*/ diff --git a/exceptions/StormyInning.java b/exceptions/StormyInning.java index e00a5880..fede8f6a 100644 --- a/exceptions/StormyInning.java +++ b/exceptions/StormyInning.java @@ -1,4 +1,4 @@ -//: exceptions/StormyInning.java +// exceptions/StormyInning.java // ©2015 MindView LLC: see Copyright.txt // Overridden methods can throw only the exceptions // specified in their base-class versions, or exceptions @@ -77,4 +77,5 @@ public class StormyInning extends Inning implements Storm { System.out.println("Generic baseball exception"); } } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/exceptions/Switch.java b/exceptions/Switch.java index 1f74daf1..fc709262 100644 --- a/exceptions/Switch.java +++ b/exceptions/Switch.java @@ -1,4 +1,4 @@ -//: exceptions/Switch.java +// exceptions/Switch.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -9,4 +9,4 @@ public class Switch { public void off() { state = false; print(this); } @Override public String toString() { return state ? "on" : "off"; } -} ///:~ +} diff --git a/exceptions/TurnOffChecking.java b/exceptions/TurnOffChecking.java index a9330531..6318321d 100644 --- a/exceptions/TurnOffChecking.java +++ b/exceptions/TurnOffChecking.java @@ -1,4 +1,4 @@ -//: exceptions/TurnOffChecking.java +// exceptions/TurnOffChecking.java // ©2015 MindView LLC: see Copyright.txt // "Turning off" Checked exceptions. import java.io.*; @@ -49,9 +49,10 @@ public class TurnOffChecking { } } } -} /* Output: +} +/* Output: FileNotFoundException: java.io.FileNotFoundException IOException: java.io.IOException Throwable: java.lang.RuntimeException: Where am I? SomeOtherException: SomeOtherException -*///:~ +*/ diff --git a/exceptions/WhoCalled.java b/exceptions/WhoCalled.java index 08548acb..f0666dc3 100644 --- a/exceptions/WhoCalled.java +++ b/exceptions/WhoCalled.java @@ -1,4 +1,4 @@ -//: exceptions/WhoCalled.java +// exceptions/WhoCalled.java // ©2015 MindView LLC: see Copyright.txt // Programmatic access to stack trace information. @@ -21,7 +21,8 @@ public class WhoCalled { System.out.println("--------------------------------"); h(); } -} /* Output: +} +/* Output: f main -------------------------------- @@ -33,4 +34,4 @@ f g h main -*///:~ +*/ diff --git a/exceptions/WithFinally.java b/exceptions/WithFinally.java index 64792a4f..f2a2fcce 100644 --- a/exceptions/WithFinally.java +++ b/exceptions/WithFinally.java @@ -1,4 +1,4 @@ -//: exceptions/WithFinally.java +// exceptions/WithFinally.java // ©2015 MindView LLC: see Copyright.txt // Finally Guarantees cleanup. @@ -17,7 +17,8 @@ public class WithFinally { sw.off(); } } -} /* Output: +} +/* Output: on off -*///:~ +*/ diff --git a/generics/Apply.java b/generics/Apply.java index 6ae4e1d0..e37517d0 100644 --- a/generics/Apply.java +++ b/generics/Apply.java @@ -1,4 +1,4 @@ -//: generics/Apply.java +// generics/Apply.java // ©2015 MindView LLC: see Copyright.txt // {main: ApplyTest} import java.lang.reflect.*; @@ -69,7 +69,8 @@ class ApplyTest { } Apply.apply(shapeQ, Shape.class.getMethod("rotate")); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Shape@139a55 rotate Shape@106d69c rotate Shape@52e922 rotate @@ -91,4 +92,4 @@ Shape@1f3c5b5 rotate Square@164951d rotate Shape@11210ee rotate Square@17e1886 rotate -*///:~ +*/ diff --git a/generics/ArrayMaker.java b/generics/ArrayMaker.java index ab97959b..3e266c65 100644 --- a/generics/ArrayMaker.java +++ b/generics/ArrayMaker.java @@ -1,4 +1,4 @@ -//: generics/ArrayMaker.java +// generics/ArrayMaker.java // ©2015 MindView LLC: see Copyright.txt import java.lang.reflect.*; import java.util.*; @@ -16,6 +16,7 @@ public class ArrayMaker { String[] stringArray = stringMaker.create(9); System.out.println(Arrays.toString(stringArray)); } -} /* Output: +} +/* Output: [null, null, null, null, null, null, null, null, null] -*///:~ +*/ diff --git a/generics/ArrayOfGeneric.java b/generics/ArrayOfGeneric.java index 26025fc3..18fec270 100644 --- a/generics/ArrayOfGeneric.java +++ b/generics/ArrayOfGeneric.java @@ -1,4 +1,4 @@ -//: generics/ArrayOfGeneric.java +// generics/ArrayOfGeneric.java // ©2015 MindView LLC: see Copyright.txt public class ArrayOfGeneric { @@ -16,6 +16,7 @@ public class ArrayOfGeneric { // Discovers type mismatch at compile time: //! gia[2] = new Generic(); } -} /* Output: +} +/* Output: Generic[] -*///:~ +*/ diff --git a/generics/ArrayOfGenericReference.java b/generics/ArrayOfGenericReference.java index 7b135797..7ab992dc 100644 --- a/generics/ArrayOfGenericReference.java +++ b/generics/ArrayOfGenericReference.java @@ -1,8 +1,8 @@ -//: generics/ArrayOfGenericReference.java +// generics/ArrayOfGenericReference.java // ©2015 MindView LLC: see Copyright.txt class Generic {} public class ArrayOfGenericReference { static Generic[] gia; -} ///:~ +} diff --git a/generics/BankTeller.java b/generics/BankTeller.java index d0489eb0..4f5b9aff 100644 --- a/generics/BankTeller.java +++ b/generics/BankTeller.java @@ -1,4 +1,4 @@ -//: generics/BankTeller.java +// generics/BankTeller.java // ©2015 MindView LLC: see Copyright.txt // A very simple bank teller simulation. import java.util.*; @@ -39,7 +39,8 @@ public class BankTeller { for(Customer c : line) serve(tellers.get(rand.nextInt(tellers.size())), c); } -} /* Output: +} +/* Output: Teller 3 serves Customer 1 Teller 2 serves Customer 2 Teller 3 serves Customer 3 @@ -55,4 +56,4 @@ Teller 4 serves Customer 12 Teller 2 serves Customer 13 Teller 1 serves Customer 14 Teller 1 serves Customer 15 -*///:~ +*/ diff --git a/generics/BasicBounds.java b/generics/BasicBounds.java index 8b6c44f7..12fa56f3 100644 --- a/generics/BasicBounds.java +++ b/generics/BasicBounds.java @@ -1,4 +1,4 @@ -//: generics/BasicBounds.java +// generics/BasicBounds.java // ©2015 MindView LLC: see Copyright.txt interface HasColor { java.awt.Color getColor(); } @@ -58,4 +58,5 @@ public class BasicBounds { solid.getY(); solid.weight(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/BasicGeneratorDemo.java b/generics/BasicGeneratorDemo.java index a237aebf..1cea1040 100644 --- a/generics/BasicGeneratorDemo.java +++ b/generics/BasicGeneratorDemo.java @@ -1,4 +1,4 @@ -//: generics/BasicGeneratorDemo.java +// generics/BasicGeneratorDemo.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -9,10 +9,11 @@ public class BasicGeneratorDemo { for(int i = 0; i < 5; i++) System.out.println(gen.next()); } -} /* Output: +} +/* Output: CountedObject 0 CountedObject 1 CountedObject 2 CountedObject 3 CountedObject 4 -*///:~ +*/ diff --git a/generics/BasicHolder.java b/generics/BasicHolder.java index b88668f9..d30d6be4 100644 --- a/generics/BasicHolder.java +++ b/generics/BasicHolder.java @@ -1,4 +1,4 @@ -//: generics/BasicHolder.java +// generics/BasicHolder.java // ©2015 MindView LLC: see Copyright.txt public class BasicHolder { @@ -8,4 +8,4 @@ public class BasicHolder { void f() { System.out.println(element.getClass().getSimpleName()); } -} ///:~ +} diff --git a/generics/ByteSet.java b/generics/ByteSet.java index db4e75bd..6fadcb50 100644 --- a/generics/ByteSet.java +++ b/generics/ByteSet.java @@ -1,4 +1,4 @@ -//: generics/ByteSet.java +// generics/ByteSet.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -9,4 +9,4 @@ public class ByteSet { // But you can't do this: // Set mySet2 = new HashSet<>( // Arrays.asList(1,2,3,4,5,6,7,8,9)); -} ///:~ +} diff --git a/generics/CRGWithBasicHolder.java b/generics/CRGWithBasicHolder.java index 76ca69ed..34b8c4e4 100644 --- a/generics/CRGWithBasicHolder.java +++ b/generics/CRGWithBasicHolder.java @@ -1,4 +1,4 @@ -//: generics/CRGWithBasicHolder.java +// generics/CRGWithBasicHolder.java // ©2015 MindView LLC: see Copyright.txt class Subtype extends BasicHolder {} @@ -10,6 +10,7 @@ public class CRGWithBasicHolder { Subtype st3 = st1.get(); st1.f(); } -} /* Output: +} +/* Output: Subtype -*///:~ +*/ diff --git a/generics/CaptureConversion.java b/generics/CaptureConversion.java index 3716aa68..99eaf9f3 100644 --- a/generics/CaptureConversion.java +++ b/generics/CaptureConversion.java @@ -1,4 +1,4 @@ -//: generics/CaptureConversion.java +// generics/CaptureConversion.java // ©2015 MindView LLC: see Copyright.txt public class CaptureConversion { @@ -21,8 +21,9 @@ public class CaptureConversion { Holder wildcarded = new Holder<>(1.0); f2(wildcarded); } -} /* Output: +} +/* Output: Integer Object Double -*///:~ +*/ diff --git a/generics/CheckedList.java b/generics/CheckedList.java index 60e8eb5e..c355a66f 100644 --- a/generics/CheckedList.java +++ b/generics/CheckedList.java @@ -1,4 +1,4 @@ -//: generics/CheckedList.java +// generics/CheckedList.java // ©2015 MindView LLC: see Copyright.txt // Using Collection.checkedList(). import typeinfo.pets.*; @@ -25,8 +25,9 @@ public class CheckedList { pets.add(new Dog()); pets.add(new Cat()); } -} /* Output: +} +/* Output: Expected: java.lang.ClassCastException: Attempt to insert class typeinfo.pets.Cat element into collection with element type class typeinfo.pets.Dog -*///:~ +*/ diff --git a/generics/ClassCasting.java b/generics/ClassCasting.java index f290a894..50f16dc8 100644 --- a/generics/ClassCasting.java +++ b/generics/ClassCasting.java @@ -1,4 +1,4 @@ -//: generics/ClassCasting.java +// generics/ClassCasting.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; import java.util.*; @@ -13,4 +13,4 @@ public class ClassCasting { // List<>.class.cast(in.readObject()); List lw2 = List.class.cast(in.readObject()); } -} ///:~ +} diff --git a/generics/ClassTypeCapture.java b/generics/ClassTypeCapture.java index c94e53c0..976f2357 100644 --- a/generics/ClassTypeCapture.java +++ b/generics/ClassTypeCapture.java @@ -1,4 +1,4 @@ -//: generics/ClassTypeCapture.java +// generics/ClassTypeCapture.java // ©2015 MindView LLC: see Copyright.txt class Building {} @@ -22,9 +22,10 @@ public class ClassTypeCapture { System.out.println(ctt2.f(new Building())); System.out.println(ctt2.f(new House())); } -} /* Output: +} +/* Output: true true false true -*///:~ +*/ diff --git a/generics/ComparablePet.java b/generics/ComparablePet.java index 840a065f..ebf1ae19 100644 --- a/generics/ComparablePet.java +++ b/generics/ComparablePet.java @@ -1,8 +1,8 @@ -//: generics/ComparablePet.java +// generics/ComparablePet.java // ©2015 MindView LLC: see Copyright.txt public class ComparablePet implements Comparable { @Override public int compareTo(ComparablePet arg) { return 0; } -} ///:~ +} diff --git a/generics/CompilerIntelligence.java b/generics/CompilerIntelligence.java index 70bdedae..e82a1f04 100644 --- a/generics/CompilerIntelligence.java +++ b/generics/CompilerIntelligence.java @@ -1,4 +1,4 @@ -//: generics/CompilerIntelligence.java +// generics/CompilerIntelligence.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -10,4 +10,5 @@ public class CompilerIntelligence { flist.contains(new Apple()); // Argument is 'Object' flist.indexOf(new Apple()); // Argument is 'Object' } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/CountedObject.java b/generics/CountedObject.java index dae5b0e9..51a53e99 100644 --- a/generics/CountedObject.java +++ b/generics/CountedObject.java @@ -1,4 +1,4 @@ -//: generics/CountedObject.java +// generics/CountedObject.java // ©2015 MindView LLC: see Copyright.txt public class CountedObject { @@ -7,4 +7,4 @@ public class CountedObject { public long id() { return id; } @Override public String toString() { return "CountedObject " + id;} -} ///:~ +} diff --git a/generics/CovariantArrays.java b/generics/CovariantArrays.java index 9f46be67..b9896115 100644 --- a/generics/CovariantArrays.java +++ b/generics/CovariantArrays.java @@ -1,4 +1,4 @@ -//: generics/CovariantArrays.java +// generics/CovariantArrays.java // ©2015 MindView LLC: see Copyright.txt class Fruit {} @@ -21,7 +21,8 @@ public class CovariantArrays { fruit[0] = new Orange(); // ArrayStoreException } catch(Exception e) { System.out.println(e); } } -} /* Output: +} +/* Output: java.lang.ArrayStoreException: Fruit java.lang.ArrayStoreException: Orange -*///:~ +*/ diff --git a/generics/CovariantReturnTypes.java b/generics/CovariantReturnTypes.java index 2cb15bc4..af04950b 100644 --- a/generics/CovariantReturnTypes.java +++ b/generics/CovariantReturnTypes.java @@ -1,4 +1,4 @@ -//: generics/CovariantReturnTypes.java +// generics/CovariantReturnTypes.java // ©2015 MindView LLC: see Copyright.txt class Base {} @@ -18,4 +18,4 @@ public class CovariantReturnTypes { void test(DerivedGetter d) { Derived d2 = d.get(); } -} ///:~ +} diff --git a/generics/CreatorGeneric.java b/generics/CreatorGeneric.java index 9e0c44da..5f301339 100644 --- a/generics/CreatorGeneric.java +++ b/generics/CreatorGeneric.java @@ -1,4 +1,4 @@ -//: generics/CreatorGeneric.java +// generics/CreatorGeneric.java // ©2015 MindView LLC: see Copyright.txt abstract class GenericWithCreate { @@ -22,6 +22,7 @@ public class CreatorGeneric { Creator c = new Creator(); c.f(); } -} /* Output: +} +/* Output: X -*///:~ +*/ diff --git a/generics/CuriouslyRecurringGeneric.java b/generics/CuriouslyRecurringGeneric.java index e7ede29d..8e6d6cb6 100644 --- a/generics/CuriouslyRecurringGeneric.java +++ b/generics/CuriouslyRecurringGeneric.java @@ -1,7 +1,7 @@ -//: generics/CuriouslyRecurringGeneric.java +// generics/CuriouslyRecurringGeneric.java // ©2015 MindView LLC: see Copyright.txt class GenericType {} public class CuriouslyRecurringGeneric - extends GenericType {} ///:~ + extends GenericType {} diff --git a/generics/Diamond.java b/generics/Diamond.java index 4f87edec..59ea349b 100644 --- a/generics/Diamond.java +++ b/generics/Diamond.java @@ -1,4 +1,4 @@ -//: generics/Diamond.java +// generics/Diamond.java // ©2015 MindView LLC: see Copyright.txt public class Diamond { @@ -13,4 +13,5 @@ public class Diamond { // h3.set("Not an Automobile"); // Error // h3.set(1); // Error } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/DogsAndRobots.cpp b/generics/DogsAndRobots.cpp index 7f82b60f..7365a4f8 100644 --- a/generics/DogsAndRobots.cpp +++ b/generics/DogsAndRobots.cpp @@ -1,4 +1,4 @@ -//: generics/DogsAndRobots.cpp +// generics/DogsAndRobots.cpp // ©2015 MindView LLC: see Copyright.txt class Dog { @@ -25,4 +25,4 @@ int main() { Robot r; perform(d); perform(r); -} ///:~ +} diff --git a/generics/DogsAndRobots.java b/generics/DogsAndRobots.java index c86300a6..471c1bde 100644 --- a/generics/DogsAndRobots.java +++ b/generics/DogsAndRobots.java @@ -1,4 +1,4 @@ -//: generics/DogsAndRobots.java +// generics/DogsAndRobots.java // ©2015 MindView LLC: see Copyright.txt // No latent typing in Java import typeinfo.pets.*; @@ -33,9 +33,10 @@ public class DogsAndRobots { Communicate.perform(d); Communicate.perform(r); } -} /* Output: +} +/* Output: Woof! Sitting Click! Clank! -*///:~ +*/ diff --git a/generics/DogsAndRobots.py b/generics/DogsAndRobots.py index 1022a3dd..61160077 100644 --- a/generics/DogsAndRobots.py +++ b/generics/DogsAndRobots.py @@ -1,4 +1,4 @@ -#: generics/DogsAndRobots.py +# generics/DogsAndRobots.py # ©2015 MindView LLC: see Copyright.txt class Dog: @@ -25,4 +25,4 @@ a = Dog() b = Robot() perform(a) perform(b) -#:~ +#> diff --git a/generics/DynamicProxyMixin.java b/generics/DynamicProxyMixin.java index 11b06330..d0ae5f0b 100644 --- a/generics/DynamicProxyMixin.java +++ b/generics/DynamicProxyMixin.java @@ -1,4 +1,4 @@ -//: generics/DynamicProxyMixin.java +// generics/DynamicProxyMixin.java // ©2015 MindView LLC: see Copyright.txt import java.lang.reflect.*; import java.util.*; @@ -54,8 +54,9 @@ public class DynamicProxyMixin { System.out.println(t.getStamp()); System.out.println(s.getSerialNumber()); } -} /* Output: +} +/* Output: Hello 1434408462833 1 -*///:~ +*/ diff --git a/generics/EpicBattle.java b/generics/EpicBattle.java index 06ffe10a..655a7c85 100644 --- a/generics/EpicBattle.java +++ b/generics/EpicBattle.java @@ -1,4 +1,4 @@ -//: generics/EpicBattle.java +// generics/EpicBattle.java // ©2015 MindView LLC: see Copyright.txt // Demonstrating bounds in Java generics. import java.util.*; @@ -64,4 +64,5 @@ public class EpicBattle { // But you can't do this: // List dogBoys; } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/Erased.java b/generics/Erased.java index 97530c2a..dca79776 100644 --- a/generics/Erased.java +++ b/generics/Erased.java @@ -1,4 +1,4 @@ -//: generics/Erased.java +// generics/Erased.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Won't compile) @@ -10,4 +10,4 @@ public class Erased { T[] array = new T[SIZE]; // Error T[] array = (T)new Object[SIZE]; // Unchecked warning } -} ///:~ +} diff --git a/generics/ErasedTypeEquivalence.java b/generics/ErasedTypeEquivalence.java index 111f0432..931b4ee8 100644 --- a/generics/ErasedTypeEquivalence.java +++ b/generics/ErasedTypeEquivalence.java @@ -1,4 +1,4 @@ -//: generics/ErasedTypeEquivalence.java +// generics/ErasedTypeEquivalence.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -8,6 +8,7 @@ public class ErasedTypeEquivalence { Class c2 = new ArrayList().getClass(); System.out.println(c1 == c2); } -} /* Output: +} +/* Output: true -*///:~ +*/ diff --git a/generics/ErasureAndInheritance.java b/generics/ErasureAndInheritance.java index 000ce1a1..c0864206 100644 --- a/generics/ErasureAndInheritance.java +++ b/generics/ErasureAndInheritance.java @@ -1,4 +1,4 @@ -//: generics/ErasureAndInheritance.java +// generics/ErasureAndInheritance.java // ©2015 MindView LLC: see Copyright.txt class GenericBase { @@ -23,4 +23,5 @@ public class ErasureAndInheritance { Object obj = d2.get(); d2.set(obj); // Warning here! } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/ExplicitTypeSpecification.java b/generics/ExplicitTypeSpecification.java index 1806514e..28596c29 100644 --- a/generics/ExplicitTypeSpecification.java +++ b/generics/ExplicitTypeSpecification.java @@ -1,4 +1,4 @@ -//: generics/ExplicitTypeSpecification.java +// generics/ExplicitTypeSpecification.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -9,4 +9,5 @@ public class ExplicitTypeSpecification { public static void main(String[] args) { f(New.>map()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/FactoryConstraint.java b/generics/FactoryConstraint.java index 60112495..caaa5ec1 100644 --- a/generics/FactoryConstraint.java +++ b/generics/FactoryConstraint.java @@ -1,4 +1,4 @@ -//: generics/FactoryConstraint.java +// generics/FactoryConstraint.java // ©2015 MindView LLC: see Copyright.txt interface FactoryI { @@ -34,4 +34,5 @@ public class FactoryConstraint { new Foo2<>(new IntegerFactory()); new Foo2<>(new Widget.Factory()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/Fibonacci.java b/generics/Fibonacci.java index 56ae9b79..5be3cf1d 100644 --- a/generics/Fibonacci.java +++ b/generics/Fibonacci.java @@ -1,4 +1,4 @@ -//: generics/Fibonacci.java +// generics/Fibonacci.java // ©2015 MindView LLC: see Copyright.txt // Generate a Fibonacci sequence. import com.mindviewinc.util.*; @@ -16,6 +16,7 @@ public class Fibonacci implements Generator { for(int i = 0; i < 18; i++) System.out.print(gen.next() + " "); } -} /* Output: +} +/* Output: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 -*///:~ +*/ diff --git a/generics/Fill.java b/generics/Fill.java index 06d55048..a6bf332b 100644 --- a/generics/Fill.java +++ b/generics/Fill.java @@ -1,4 +1,4 @@ -//: generics/Fill.java +// generics/Fill.java // ©2015 MindView LLC: see Copyright.txt // Generalizing the FilledList idea // {main: FillTest} @@ -45,10 +45,11 @@ class FillTest { // Won't work. fill() is not generic enough: // Fill.fill(contractQueue, Contract.class, 3); } -} /* Output: +} +/* Output: Contract 0 Contract 1 Contract 2 TitleTransfer 3 TitleTransfer 4 -*///:~ +*/ diff --git a/generics/Fill2.java b/generics/Fill2.java index a54c87b8..13225832 100644 --- a/generics/Fill2.java +++ b/generics/Fill2.java @@ -1,4 +1,4 @@ -//: generics/Fill2.java +// generics/Fill2.java // ©2015 MindView LLC: see Copyright.txt // Using adapters to simulate latent typing. // {main: Fill2Test} @@ -77,7 +77,8 @@ class Fill2Test { for(Coffee c: coffeeQueue) print(c); } -} /* Output: +} +/* Output: Coffee 0 Coffee 1 Coffee 2 @@ -89,4 +90,4 @@ Mocha 6 Mocha 7 Mocha 8 Latte 9 -*///:~ +*/ diff --git a/generics/FilledListMaker.java b/generics/FilledListMaker.java index 696936bc..3ef4b49b 100644 --- a/generics/FilledListMaker.java +++ b/generics/FilledListMaker.java @@ -1,4 +1,4 @@ -//: generics/FilledListMaker.java +// generics/FilledListMaker.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -15,6 +15,7 @@ public class FilledListMaker { List list = stringMaker.create("Hello", 4); System.out.println(list); } -} /* Output: +} +/* Output: [Hello, Hello, Hello, Hello] -*///:~ +*/ diff --git a/generics/Functional.java b/generics/Functional.java index 7c9c9307..54d07379 100644 --- a/generics/Functional.java +++ b/generics/Functional.java @@ -1,4 +1,4 @@ -//: generics/Functional.java +// generics/Functional.java // ©2015 MindView LLC: see Copyright.txt import java.math.*; import java.util.concurrent.atomic.*; @@ -170,9 +170,10 @@ public class Functional { AtomicLong ral = reduce(lal, new AtomicLongAdder()); print(ral); - print(transform(lbd,new BigDecimalUlp())); + print(transform(lbd, new BigDecimalUlp())); } -} /* Output: +} +/* Output: 28 -26 [5, 6, 7] @@ -185,4 +186,4 @@ public class Functional { true 265 [0.000001, 0.000001, 0.000001, 0.000001] -*///:~ +*/ diff --git a/generics/Generators.java b/generics/Generators.java index 11c50bae..1088442b 100644 --- a/generics/Generators.java +++ b/generics/Generators.java @@ -1,4 +1,4 @@ -//: generics/Generators.java +// generics/Generators.java // ©2015 MindView LLC: see Copyright.txt // A utility to use with Generators. import generics.coffee.*; @@ -22,10 +22,11 @@ public class Generators { for(int i : fnumbers) System.out.print(i + ", "); } -} /* Output: +} +/* Output: Americano 0 Latte 1 Americano 2 Mocha 3 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, -*///:~ +*/ diff --git a/generics/GenericArray.java b/generics/GenericArray.java index b83cbd75..17d4b4df 100644 --- a/generics/GenericArray.java +++ b/generics/GenericArray.java @@ -1,4 +1,4 @@ -//: generics/GenericArray.java +// generics/GenericArray.java // ©2015 MindView LLC: see Copyright.txt public class GenericArray { @@ -20,4 +20,5 @@ public class GenericArray { // This is OK: Object[] oa = gai.rep(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/GenericArray2.java b/generics/GenericArray2.java index fa75c489..cd152f6f 100644 --- a/generics/GenericArray2.java +++ b/generics/GenericArray2.java @@ -1,4 +1,4 @@ -//: generics/GenericArray2.java +// generics/GenericArray2.java // ©2015 MindView LLC: see Copyright.txt public class GenericArray2 { @@ -29,8 +29,9 @@ public class GenericArray2 { System.out.println(e); } } -} /* Output: +} +/* Output: 0 1 2 3 4 5 6 7 8 9 java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer; -*///:~ +*/ diff --git a/generics/GenericArrayWithTypeToken.java b/generics/GenericArrayWithTypeToken.java index e53f6a89..86d11e9b 100644 --- a/generics/GenericArrayWithTypeToken.java +++ b/generics/GenericArrayWithTypeToken.java @@ -1,4 +1,4 @@ -//: generics/GenericArrayWithTypeToken.java +// generics/GenericArrayWithTypeToken.java // ©2015 MindView LLC: see Copyright.txt import java.lang.reflect.*; @@ -21,4 +21,5 @@ public class GenericArrayWithTypeToken { // This now works: Integer[] ia = gai.rep(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/GenericCast.java b/generics/GenericCast.java index cf3534af..e5e2f53e 100644 --- a/generics/GenericCast.java +++ b/generics/GenericCast.java @@ -1,4 +1,4 @@ -//: generics/GenericCast.java +// generics/GenericCast.java // ©2015 MindView LLC: see Copyright.txt class FixedSizeStack { @@ -24,6 +24,7 @@ public class GenericCast { System.out.print(s + " "); } } -} /* Output: +} +/* Output: J I H G F E D C B A -*///:~ +*/ diff --git a/generics/GenericHolder.java b/generics/GenericHolder.java index a3136e7c..5359ad55 100644 --- a/generics/GenericHolder.java +++ b/generics/GenericHolder.java @@ -1,4 +1,4 @@ -//: generics/GenericHolder.java +// generics/GenericHolder.java // ©2015 MindView LLC: see Copyright.txt public class GenericHolder { @@ -11,4 +11,5 @@ public class GenericHolder { holder.set("Item"); String s = holder.get(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/GenericMethods.java b/generics/GenericMethods.java index 5c7f315c..863c08af 100644 --- a/generics/GenericMethods.java +++ b/generics/GenericMethods.java @@ -1,4 +1,4 @@ -//: generics/GenericMethods.java +// generics/GenericMethods.java // ©2015 MindView LLC: see Copyright.txt public class GenericMethods { @@ -14,11 +14,12 @@ public class GenericMethods { gm.f('c'); gm.f(gm); } -} /* Output: +} +/* Output: java.lang.String java.lang.Integer java.lang.Double java.lang.Float java.lang.Character GenericMethods -*///:~ +*/ diff --git a/generics/GenericReading.java b/generics/GenericReading.java index 38c7d411..3f326081 100644 --- a/generics/GenericReading.java +++ b/generics/GenericReading.java @@ -1,4 +1,4 @@ -//: generics/GenericReading.java +// generics/GenericReading.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -40,4 +40,5 @@ public class GenericReading { public static void main(String[] args) { f1(); f2(); f3(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/GenericVarargs.java b/generics/GenericVarargs.java index e4ed1ca6..2b975d68 100644 --- a/generics/GenericVarargs.java +++ b/generics/GenericVarargs.java @@ -1,4 +1,4 @@ -//: generics/GenericVarargs.java +// generics/GenericVarargs.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -18,9 +18,10 @@ public class GenericVarargs { ls = makeList("ABCDEFFHIJKLMNOPQRSTUVWXYZ".split("")); System.out.println(ls); } -} /* Output: +} +/* Output: [A] [A, B, C] [A, B, C, D, E, F, F, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z] -*///:~ +*/ diff --git a/generics/GenericWriting.java b/generics/GenericWriting.java index c273bcda..2e2ff545 100644 --- a/generics/GenericWriting.java +++ b/generics/GenericWriting.java @@ -1,4 +1,4 @@ -//: generics/GenericWriting.java +// generics/GenericWriting.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -21,4 +21,5 @@ public class GenericWriting { writeWithWildcard(fruit, new Apple()); } public static void main(String[] args) { f1(); f2(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/GenericsAndCovariance.java b/generics/GenericsAndCovariance.java index d2c87028..6891483a 100644 --- a/generics/GenericsAndCovariance.java +++ b/generics/GenericsAndCovariance.java @@ -1,4 +1,4 @@ -//: generics/GenericsAndCovariance.java +// generics/GenericsAndCovariance.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -14,4 +14,5 @@ public class GenericsAndCovariance { // We know that it returns at least Fruit: Fruit f = flist.get(0); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/GenericsAndReturnTypes.java b/generics/GenericsAndReturnTypes.java index 30d65199..a3fffcdb 100644 --- a/generics/GenericsAndReturnTypes.java +++ b/generics/GenericsAndReturnTypes.java @@ -1,4 +1,4 @@ -//: generics/GenericsAndReturnTypes.java +// generics/GenericsAndReturnTypes.java // ©2015 MindView LLC: see Copyright.txt interface GenericGetter> { @@ -12,4 +12,4 @@ public class GenericsAndReturnTypes { Getter result = g.get(); GenericGetter gg = g.get(); // Also the base type } -} ///:~ +} diff --git a/generics/HasF.java b/generics/HasF.java index e1cc38be..2d26c2b4 100644 --- a/generics/HasF.java +++ b/generics/HasF.java @@ -1,6 +1,6 @@ -//: generics/HasF.java +// generics/HasF.java // ©2015 MindView LLC: see Copyright.txt public class HasF { public void f() { System.out.println("HasF.f()"); } -} ///:~ +} diff --git a/generics/HijackedInterface.java b/generics/HijackedInterface.java index 3514396b..aa990c03 100644 --- a/generics/HijackedInterface.java +++ b/generics/HijackedInterface.java @@ -1,4 +1,4 @@ -//: generics/HijackedInterface.java +// generics/HijackedInterface.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Won't compile) @@ -6,4 +6,4 @@ class Cat extends ComparablePet implements Comparable{ // Error: Comparable cannot be inherited with // different arguments: and public int compareTo(Cat arg) { return 0; } -} ///:~ +} diff --git a/generics/Holder.java b/generics/Holder.java index 6931a1d6..02cce510 100644 --- a/generics/Holder.java +++ b/generics/Holder.java @@ -1,4 +1,4 @@ -//: generics/Holder.java +// generics/Holder.java // ©2015 MindView LLC: see Copyright.txt public class Holder { @@ -26,8 +26,9 @@ public class Holder { // fruit.set(new Fruit()); // Cannot call set() System.out.println(fruit.equals(d)); // OK } -} /* Output: +} +/* Output: java.lang.ClassCastException: Apple cannot be cast to Orange true -*///:~ +*/ diff --git a/generics/Holder1.java b/generics/Holder1.java index fc3d1315..8d0a1ee1 100644 --- a/generics/Holder1.java +++ b/generics/Holder1.java @@ -1,4 +1,4 @@ -//: generics/Holder1.java +// generics/Holder1.java // ©2015 MindView LLC: see Copyright.txt class Automobile {} @@ -7,4 +7,4 @@ public class Holder1 { private Automobile a; public Holder1(Automobile a) { this.a = a; } Automobile get() { return a; } -} ///:~ +} diff --git a/generics/Holder2.java b/generics/Holder2.java index c5787bbb..0b4a7245 100644 --- a/generics/Holder2.java +++ b/generics/Holder2.java @@ -1,4 +1,4 @@ -//: generics/Holder2.java +// generics/Holder2.java // ©2015 MindView LLC: see Copyright.txt public class Holder2 { @@ -14,4 +14,5 @@ public class Holder2 { h2.set(1); // Autoboxes to Integer Integer x = (Integer)h2.get(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/Holder3.java b/generics/Holder3.java index 7315a35d..20083ea3 100644 --- a/generics/Holder3.java +++ b/generics/Holder3.java @@ -1,4 +1,4 @@ -//: generics/Holder3.java +// generics/Holder3.java // ©2015 MindView LLC: see Copyright.txt public class Holder3 { @@ -13,4 +13,5 @@ public class Holder3 { // h3.set("Not an Automobile"); // Error // h3.set(1); // Error } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/InheritBounds.java b/generics/InheritBounds.java index b43b8422..dcfa3c4e 100644 --- a/generics/InheritBounds.java +++ b/generics/InheritBounds.java @@ -1,4 +1,4 @@ -//: generics/InheritBounds.java +// generics/InheritBounds.java // ©2015 MindView LLC: see Copyright.txt class HoldItem { @@ -34,4 +34,5 @@ public class InheritBounds { solid2.getY(); solid2.weight(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/InstantiateGenericType.cpp b/generics/InstantiateGenericType.cpp index 3412213a..16910ed7 100644 --- a/generics/InstantiateGenericType.cpp +++ b/generics/InstantiateGenericType.cpp @@ -1,4 +1,4 @@ -//: generics/InstantiateGenericType.cpp +// generics/InstantiateGenericType.cpp // ©2015 MindView LLC: see Copyright.txt // C++, not Java! @@ -15,4 +15,4 @@ class Bar {}; int main() { Foo fb; Foo fi; // ... and it works with primitives -} ///:~ +} diff --git a/generics/InstantiateGenericType.java b/generics/InstantiateGenericType.java index 7c59ddf6..ddd89751 100644 --- a/generics/InstantiateGenericType.java +++ b/generics/InstantiateGenericType.java @@ -1,4 +1,4 @@ -//: generics/InstantiateGenericType.java +// generics/InstantiateGenericType.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -28,7 +28,8 @@ public class InstantiateGenericType { print("ClassAsFactory failed"); } } -} /* Output: +} +/* Output: ClassAsFactory succeeded ClassAsFactory failed -*///:~ +*/ diff --git a/generics/IterableFibonacci.java b/generics/IterableFibonacci.java index 673755a3..3270f22d 100644 --- a/generics/IterableFibonacci.java +++ b/generics/IterableFibonacci.java @@ -1,4 +1,4 @@ -//: generics/IterableFibonacci.java +// generics/IterableFibonacci.java // ©2015 MindView LLC: see Copyright.txt // Adapt the Fibonacci class to make it Iterable. import java.util.*; @@ -27,6 +27,7 @@ extends Fibonacci implements Iterable { for(int i : new IterableFibonacci(18)) System.out.print(i + " "); } -} /* Output: +} +/* Output: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 -*///:~ +*/ diff --git a/generics/LatentReflection.java b/generics/LatentReflection.java index a44ba094..ecdf5700 100644 --- a/generics/LatentReflection.java +++ b/generics/LatentReflection.java @@ -1,4 +1,4 @@ -//: generics/LatentReflection.java +// generics/LatentReflection.java // ©2015 MindView LLC: see Copyright.txt // Using Reflection to produce latent typing. import java.lang.reflect.*; @@ -51,11 +51,12 @@ public class LatentReflection { CommunicateReflectively.perform(new Robot()); CommunicateReflectively.perform(new Mime()); } -} /* Output: +} +/* Output: Woof! Sitting Click! Clank! Mime cannot speak Pretending to sit -*///:~ +*/ diff --git a/generics/LimitsOfInference.java b/generics/LimitsOfInference.java index 40de0b56..81b4166c 100644 --- a/generics/LimitsOfInference.java +++ b/generics/LimitsOfInference.java @@ -1,4 +1,4 @@ -//: generics/LimitsOfInference.java +// generics/LimitsOfInference.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -9,4 +9,5 @@ public class LimitsOfInference { public static void main(String[] args) { // f(New.map()); // Does not compile } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/LinkedStack.java b/generics/LinkedStack.java index dfd989ce..a7c55dfd 100644 --- a/generics/LinkedStack.java +++ b/generics/LinkedStack.java @@ -1,4 +1,4 @@ -//: generics/LinkedStack.java +// generics/LinkedStack.java // ©2015 MindView LLC: see Copyright.txt // A stack implemented with an internal linked structure. @@ -31,8 +31,9 @@ public class LinkedStack { while((s = lss.pop()) != null) System.out.println(s); } -} /* Output: +} +/* Output: stun! on Phasers -*///:~ +*/ diff --git a/generics/ListMaker.java b/generics/ListMaker.java index 6ed034c4..a1fde511 100644 --- a/generics/ListMaker.java +++ b/generics/ListMaker.java @@ -1,4 +1,4 @@ -//: generics/ListMaker.java +// generics/ListMaker.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -8,4 +8,5 @@ public class ListMaker { ListMaker stringMaker= new ListMaker<>(); List stringList = stringMaker.create(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/ListOfGenerics.java b/generics/ListOfGenerics.java index f2f109ee..33f0f727 100644 --- a/generics/ListOfGenerics.java +++ b/generics/ListOfGenerics.java @@ -1,4 +1,4 @@ -//: generics/ListOfGenerics.java +// generics/ListOfGenerics.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -6,4 +6,4 @@ public class ListOfGenerics { private List array = new ArrayList<>(); public void add(T item) { array.add(item); } public T get(int index) { return array.get(index); } -} ///:~ +} diff --git a/generics/ListOfInt.java b/generics/ListOfInt.java index 6c7c4357..c05f2003 100644 --- a/generics/ListOfInt.java +++ b/generics/ListOfInt.java @@ -1,4 +1,4 @@ -//: generics/ListOfInt.java +// generics/ListOfInt.java // ©2015 MindView LLC: see Copyright.txt // Autoboxing compensates for the inability to use // primitives in generics. @@ -12,6 +12,7 @@ public class ListOfInt { for(int i : li) System.out.print(i + " "); } -} /* Output: +} +/* Output: 0 1 2 3 4 -*///:~ +*/ diff --git a/generics/LostInformation.java b/generics/LostInformation.java index c6cfbceb..59811582 100644 --- a/generics/LostInformation.java +++ b/generics/LostInformation.java @@ -1,4 +1,4 @@ -//: generics/LostInformation.java +// generics/LostInformation.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -22,9 +22,10 @@ public class LostInformation { System.out.println(Arrays.toString( p.getClass().getTypeParameters())); } -} /* Output: +} +/* Output: [E] [K, V] [Q] [POSITION, MOMENTUM] -*///:~ +*/ diff --git a/generics/Manipulation.java b/generics/Manipulation.java index ec257301..a8292f44 100644 --- a/generics/Manipulation.java +++ b/generics/Manipulation.java @@ -1,4 +1,4 @@ -//: generics/Manipulation.java +// generics/Manipulation.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Will not compile) @@ -16,4 +16,5 @@ public class Manipulation { new Manipulator<>(hf); manipulator.manipulate(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/Manipulator2.java b/generics/Manipulator2.java index e135349a..15d424d0 100644 --- a/generics/Manipulator2.java +++ b/generics/Manipulator2.java @@ -1,8 +1,8 @@ -//: generics/Manipulator2.java +// generics/Manipulator2.java // ©2015 MindView LLC: see Copyright.txt class Manipulator2 { private T obj; public Manipulator2(T x) { obj = x; } public void manipulate() { obj.f(); } -} ///:~ +} diff --git a/generics/Manipulator3.java b/generics/Manipulator3.java index 48e475c6..77102858 100644 --- a/generics/Manipulator3.java +++ b/generics/Manipulator3.java @@ -1,8 +1,8 @@ -//: generics/Manipulator3.java +// generics/Manipulator3.java // ©2015 MindView LLC: see Copyright.txt class Manipulator3 { private HasF obj; public Manipulator3(HasF x) { obj = x; } public void manipulate() { obj.f(); } -} ///:~ +} diff --git a/generics/Mixins.cpp b/generics/Mixins.cpp index 090e05ed..bb13f8a5 100644 --- a/generics/Mixins.cpp +++ b/generics/Mixins.cpp @@ -1,4 +1,4 @@ -//: generics/Mixins.cpp +// generics/Mixins.cpp // ©2015 MindView LLC: see Copyright.txt #include #include @@ -38,7 +38,8 @@ int main() { " " << mixin1.getSerialNumber() << endl; cout << mixin2.get() << " " << mixin2.getStamp() << " " << mixin2.getSerialNumber() << endl; -} /* Output: +} +/* Output: test string 1 1129840250 1 test string 2 1129840250 2 -*///:~ +*/ diff --git a/generics/Mixins.java b/generics/Mixins.java index 1e6e3265..3b255716 100644 --- a/generics/Mixins.java +++ b/generics/Mixins.java @@ -1,4 +1,4 @@ -//: generics/Mixins.java +// generics/Mixins.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -58,7 +58,8 @@ public class Mixins { System.out.println(mixin2.get() + " " + mixin2.getStamp() + " " + mixin2.getSerialNumber()); } -} /* Output: +} +/* Output: test string 1 1434408464412 1 test string 2 1434408464413 2 -*///:~ +*/ diff --git a/generics/MultipleInterfaceVariants.java b/generics/MultipleInterfaceVariants.java index 5dc651bf..3544002f 100644 --- a/generics/MultipleInterfaceVariants.java +++ b/generics/MultipleInterfaceVariants.java @@ -1,4 +1,4 @@ -//: generics/MultipleInterfaceVariants.java +// generics/MultipleInterfaceVariants.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Won't compile) @@ -6,4 +6,4 @@ interface Payable {} class Employee implements Payable {} class Hourly extends Employee - implements Payable {} ///:~ + implements Payable {} diff --git a/generics/NeedCasting.java b/generics/NeedCasting.java index 058c843b..95b2e2b3 100644 --- a/generics/NeedCasting.java +++ b/generics/NeedCasting.java @@ -1,4 +1,4 @@ -//: generics/NeedCasting.java +// generics/NeedCasting.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; import java.util.*; @@ -10,4 +10,4 @@ public class NeedCasting { new FileInputStream(args[0])); List shapes = (List)in.readObject(); } -} ///:~ +} diff --git a/generics/NonCovariantGenerics.java b/generics/NonCovariantGenerics.java index ce1f1021..d0402f54 100644 --- a/generics/NonCovariantGenerics.java +++ b/generics/NonCovariantGenerics.java @@ -1,4 +1,4 @@ -//: generics/NonCovariantGenerics.java +// generics/NonCovariantGenerics.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Won't compile) import java.util.*; @@ -6,4 +6,4 @@ import java.util.*; public class NonCovariantGenerics { // Compile Error: incompatible types: List flist = new ArrayList(); -} ///:~ +} diff --git a/generics/NotSelfBounded.java b/generics/NotSelfBounded.java index a501faf0..4d9c8df8 100644 --- a/generics/NotSelfBounded.java +++ b/generics/NotSelfBounded.java @@ -1,4 +1,4 @@ -//: generics/NotSelfBounded.java +// generics/NotSelfBounded.java // ©2015 MindView LLC: see Copyright.txt public class NotSelfBounded { @@ -19,4 +19,4 @@ class C2 extends NotSelfBounded { class D2 {} // Now this is OK: -class E2 extends NotSelfBounded {} ///:~ +class E2 extends NotSelfBounded {} diff --git a/generics/OrdinaryArguments.java b/generics/OrdinaryArguments.java index ce0781e9..fa898c63 100644 --- a/generics/OrdinaryArguments.java +++ b/generics/OrdinaryArguments.java @@ -1,4 +1,4 @@ -//: generics/OrdinaryArguments.java +// generics/OrdinaryArguments.java // ©2015 MindView LLC: see Copyright.txt class OrdinarySetter { @@ -21,7 +21,8 @@ public class OrdinaryArguments { ds.set(derived); ds.set(base); // Compiles: overloaded, not overridden! } -} /* Output: +} +/* Output: DerivedSetter.set(Derived) OrdinarySetter.set(Base) -*///:~ +*/ diff --git a/generics/Performs.java b/generics/Performs.java index 3057dae5..6cbbf25a 100644 --- a/generics/Performs.java +++ b/generics/Performs.java @@ -1,7 +1,7 @@ -//: generics/Performs.java +// generics/Performs.java // ©2015 MindView LLC: see Copyright.txt public interface Performs { void speak(); void sit(); -} ///:~ +} diff --git a/generics/PlainGenericInheritance.java b/generics/PlainGenericInheritance.java index a4dc6387..8e4f6514 100644 --- a/generics/PlainGenericInheritance.java +++ b/generics/PlainGenericInheritance.java @@ -1,4 +1,4 @@ -//: generics/PlainGenericInheritance.java +// generics/PlainGenericInheritance.java // ©2015 MindView LLC: see Copyright.txt class GenericSetter { // Not self-bounded @@ -21,7 +21,8 @@ public class PlainGenericInheritance { dgs.set(derived); dgs.set(base); // Compiles: overloaded, not overridden! } -} /* Output: +} +/* Output: DerivedGS.set(Derived) GenericSetter.set(Base) -*///:~ +*/ diff --git a/generics/PrimitiveGenericTest.java b/generics/PrimitiveGenericTest.java index 7a3bcabc..751735f4 100644 --- a/generics/PrimitiveGenericTest.java +++ b/generics/PrimitiveGenericTest.java @@ -1,4 +1,4 @@ -//: generics/PrimitiveGenericTest.java +// generics/PrimitiveGenericTest.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -25,7 +25,8 @@ public class PrimitiveGenericTest { // int[] b = // FArray.fill(new int[7], new RandIntGenerator()); } -} /* Output: +} +/* Output: YNzbrnyGcF OWZnTcQrGs eGZMmJMRoE @@ -40,4 +41,4 @@ bkInaMesbt 5202 2209 5458 -*///:~ +*/ diff --git a/generics/RandomList.java b/generics/RandomList.java index f012312a..25c80301 100644 --- a/generics/RandomList.java +++ b/generics/RandomList.java @@ -1,4 +1,4 @@ -//: generics/RandomList.java +// generics/RandomList.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -17,6 +17,7 @@ public class RandomList { for(int i = 0; i < 11; i++) System.out.print(rs.select() + " "); } -} /* Output: +} +/* Output: brown over fox quick quick dog brown The brown lazy brown -*///:~ +*/ diff --git a/generics/RestrictedComparablePets.java b/generics/RestrictedComparablePets.java index 95f39402..1772fcfd 100644 --- a/generics/RestrictedComparablePets.java +++ b/generics/RestrictedComparablePets.java @@ -1,4 +1,4 @@ -//: generics/RestrictedComparablePets.java +// generics/RestrictedComparablePets.java // ©2015 MindView LLC: see Copyright.txt class Hamster extends ComparablePet @@ -10,4 +10,4 @@ implements Comparable { class Gecko extends ComparablePet { public int compareTo(ComparablePet arg) { return 0; } -} ///:~ +} diff --git a/generics/ReturnGenericType.java b/generics/ReturnGenericType.java index 454af769..15e7b66c 100644 --- a/generics/ReturnGenericType.java +++ b/generics/ReturnGenericType.java @@ -1,8 +1,8 @@ -//: generics/ReturnGenericType.java +// generics/ReturnGenericType.java // ©2015 MindView LLC: see Copyright.txt class ReturnGenericType { private T obj; public ReturnGenericType(T x) { obj = x; } public T get() { return obj; } -} ///:~ +} diff --git a/generics/SelfBounding.java b/generics/SelfBounding.java index a578fde5..86437e5f 100644 --- a/generics/SelfBounding.java +++ b/generics/SelfBounding.java @@ -1,4 +1,4 @@ -//: generics/SelfBounding.java +// generics/SelfBounding.java // ©2015 MindView LLC: see Copyright.txt class SelfBounded> { @@ -34,4 +34,5 @@ public class SelfBounding { C c = new C(); c = c.setAndGet(new C()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/SelfBoundingAndCovariantArguments.java b/generics/SelfBoundingAndCovariantArguments.java index 0d589390..c6d02955 100644 --- a/generics/SelfBoundingAndCovariantArguments.java +++ b/generics/SelfBoundingAndCovariantArguments.java @@ -1,4 +1,4 @@ -//: generics/SelfBoundingAndCovariantArguments.java +// generics/SelfBoundingAndCovariantArguments.java // ©2015 MindView LLC: see Copyright.txt interface SelfBoundSetter> { @@ -14,4 +14,4 @@ public class SelfBoundingAndCovariantArguments { // set(Setter) in SelfBoundSetter // cannot be applied to (SelfBoundSetter) } -} ///:~ +} diff --git a/generics/SelfBoundingMethods.java b/generics/SelfBoundingMethods.java index 06a5d394..d5a0e65f 100644 --- a/generics/SelfBoundingMethods.java +++ b/generics/SelfBoundingMethods.java @@ -1,4 +1,4 @@ -//: generics/SelfBoundingMethods.java +// generics/SelfBoundingMethods.java // ©2015 MindView LLC: see Copyright.txt public class SelfBoundingMethods { @@ -8,4 +8,5 @@ public class SelfBoundingMethods { public static void main(String[] args) { A a = f(new A()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/SimpleDogsAndRobots.java b/generics/SimpleDogsAndRobots.java index ffad22d9..4e2f10a0 100644 --- a/generics/SimpleDogsAndRobots.java +++ b/generics/SimpleDogsAndRobots.java @@ -1,4 +1,4 @@ -//: generics/SimpleDogsAndRobots.java +// generics/SimpleDogsAndRobots.java // ©2015 MindView LLC: see Copyright.txt // Removing the generic; code still works. @@ -14,9 +14,10 @@ public class SimpleDogsAndRobots { CommunicateSimply.perform(new PerformingDog()); CommunicateSimply.perform(new Robot()); } -} /* Output: +} +/* Output: Woof! Sitting Click! Clank! -*///:~ +*/ diff --git a/generics/SimpleHolder.java b/generics/SimpleHolder.java index 68c54d11..830012df 100644 --- a/generics/SimpleHolder.java +++ b/generics/SimpleHolder.java @@ -1,4 +1,4 @@ -//: generics/SimpleHolder.java +// generics/SimpleHolder.java // ©2015 MindView LLC: see Copyright.txt public class SimpleHolder { @@ -10,4 +10,5 @@ public class SimpleHolder { holder.set("Item"); String s = (String)holder.get(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/SimpleQueue.java b/generics/SimpleQueue.java index c146428d..14691a95 100644 --- a/generics/SimpleQueue.java +++ b/generics/SimpleQueue.java @@ -1,4 +1,4 @@ -//: generics/SimpleQueue.java +// generics/SimpleQueue.java // ©2015 MindView LLC: see Copyright.txt // A different kind of container that is Iterable import java.util.*; @@ -11,4 +11,4 @@ public class SimpleQueue implements Iterable { public Iterator iterator() { return storage.iterator(); } -} ///:~ +} diff --git a/generics/SimplerPets.java b/generics/SimplerPets.java index 00a5e2f3..c2e3f5a1 100644 --- a/generics/SimplerPets.java +++ b/generics/SimplerPets.java @@ -1,4 +1,4 @@ -//: generics/SimplerPets.java +// generics/SimplerPets.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import java.util.*; @@ -9,4 +9,5 @@ public class SimplerPets { Map> petPeople = New.map(); // Rest of the code is the same... } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/Store.java b/generics/Store.java index 107c387e..6e87522e 100644 --- a/generics/Store.java +++ b/generics/Store.java @@ -1,4 +1,4 @@ -//: generics/Store.java +// generics/Store.java // ©2015 MindView LLC: see Copyright.txt // Building up a complex model using generic containers. import java.util.*; @@ -70,7 +70,8 @@ public class Store extends ArrayList { public static void main(String[] args) { System.out.println(new Store(14, 5, 10)); } -} /* Output: (First 8 Lines) +} +/* Output: (First 8 Lines) 258: Test, price: $400.99 861: Test, price: $160.99 868: Test, price: $417.99 @@ -80,4 +81,4 @@ public class Store extends ArrayList { 520: Test, price: $554.99 140: Test, price: $530.99 ... -*///:~ +*/ diff --git a/generics/SuperTypeWildcards.java b/generics/SuperTypeWildcards.java index ac42bef0..76ddc69e 100644 --- a/generics/SuperTypeWildcards.java +++ b/generics/SuperTypeWildcards.java @@ -1,4 +1,4 @@ -//: generics/SuperTypeWildcards.java +// generics/SuperTypeWildcards.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -8,4 +8,4 @@ public class SuperTypeWildcards { apples.add(new Jonathan()); // apples.add(new Fruit()); // Error } -} ///:~ +} diff --git a/generics/Templates.cpp b/generics/Templates.cpp index 737ab15c..d0be2a56 100644 --- a/generics/Templates.cpp +++ b/generics/Templates.cpp @@ -1,4 +1,4 @@ -//: generics/Templates.cpp +// generics/Templates.cpp // ©2015 MindView LLC: see Copyright.txt #include using namespace std; @@ -19,6 +19,6 @@ int main() { HasF hf; Manipulator manipulator(hf); manipulator.manipulate(); -} /* Output: +} +/* Output: HasF::f() -///:~ diff --git a/generics/ThrowGenericException.java b/generics/ThrowGenericException.java index cbec7d71..41de8ab1 100644 --- a/generics/ThrowGenericException.java +++ b/generics/ThrowGenericException.java @@ -1,4 +1,4 @@ -//: generics/ThrowGenericException.java +// generics/ThrowGenericException.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -71,7 +71,8 @@ public class ThrowGenericException { System.out.println(e); } } -} /* Output: +} +/* Output: [Hep!, Hep!, Ho!] Failure2 -*///:~ +*/ diff --git a/generics/TupleList.java b/generics/TupleList.java index f9204ec3..f1a80881 100644 --- a/generics/TupleList.java +++ b/generics/TupleList.java @@ -1,11 +1,11 @@ -//: generics/TupleList.java +// generics/TupleList.java // ©2015 MindView LLC: see Copyright.txt // Combining generic types to make complex generic types. import java.util.*; import com.mindviewinc.util.*; -public class TupleList -extends ArrayList> { +public class TupleList +extends ArrayList> { public static void main(String[] args) { TupleList tl = new TupleList<>(); @@ -14,7 +14,8 @@ extends ArrayList> { for(FourTuple i: tl) System.out.println(i); } -} /* Output: +} +/* Output: (Vehicle@139a55, Amphibian@1db9742, hi, 47) (Vehicle@106d69c, Amphibian@52e922, hi, 47) -*///:~ +*/ diff --git a/generics/TupleTest.java b/generics/TupleTest.java index 2fa6f195..932cdc56 100644 --- a/generics/TupleTest.java +++ b/generics/TupleTest.java @@ -1,4 +1,4 @@ -//: generics/TupleTest.java +// generics/TupleTest.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; @@ -6,36 +6,37 @@ class Amphibian {} class Vehicle {} public class TupleTest { - static TwoTuple f() { + static TwoTuple f() { // Autoboxing converts the int to Integer: return new TwoTuple<>("hi", 47); } - static ThreeTuple g() { + static ThreeTuple g() { return new ThreeTuple<>(new Amphibian(), "hi", 47); } static - FourTuple h() { + FourTuple h() { return new FourTuple<>( new Vehicle(), new Amphibian(), "hi", 47); } static - FiveTuple k() { + FiveTuple k(){ return new FiveTuple<>( new Vehicle(), new Amphibian(), "hi", 47, 11.1); } public static void main(String[] args) { - TwoTuple ttsi = f(); + TwoTuple ttsi = f(); System.out.println(ttsi); // ttsi.first = "there"; // Compile error: final System.out.println(g()); System.out.println(h()); System.out.println(k()); } -} /* Output: +} +/* Output: (hi, 47) (Amphibian@139a55, hi, 47) (Vehicle@1db9742, Amphibian@106d69c, hi, 47) (Vehicle@52e922, Amphibian@25154f, hi, 47, 11.1) -*///:~ +*/ diff --git a/generics/TupleTest2.java b/generics/TupleTest2.java index c73f17ec..2ea947c5 100644 --- a/generics/TupleTest2.java +++ b/generics/TupleTest2.java @@ -1,37 +1,38 @@ -//: generics/TupleTest2.java +// generics/TupleTest2.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; import static com.mindviewinc.util.Tuple.*; public class TupleTest2 { - static TwoTuple f() { + static TwoTuple f() { return tuple("hi", 47); } static TwoTuple f2() { return tuple("hi", 47); } - static ThreeTuple g() { + static ThreeTuple g() { return tuple(new Amphibian(), "hi", 47); } static - FourTuple h() { + FourTuple h() { return tuple(new Vehicle(), new Amphibian(), "hi", 47); } static - FiveTuple k() { + FiveTuple k(){ return tuple(new Vehicle(), new Amphibian(), "hi", 47, 11.1); } public static void main(String[] args) { - TwoTuple ttsi = f(); + TwoTuple ttsi = f(); System.out.println(ttsi); System.out.println(f2()); System.out.println(g()); System.out.println(h()); System.out.println(k()); } -} /* Output: +} +/* Output: (hi, 47) (hi, 47) (Amphibian@139a55, hi, 47) (Vehicle@1db9742, Amphibian@106d69c, hi, 47) (Vehicle@52e922, Amphibian@25154f, hi, 47, 11.1) -*///:~ +*/ diff --git a/generics/UnboundedWildcards1.java b/generics/UnboundedWildcards1.java index d2482717..44a819c6 100644 --- a/generics/UnboundedWildcards1.java +++ b/generics/UnboundedWildcards1.java @@ -1,4 +1,4 @@ -//: generics/UnboundedWildcards1.java +// generics/UnboundedWildcards1.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -38,4 +38,5 @@ public class UnboundedWildcards1 { assign2(wildList); assign3(wildList); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/UnboundedWildcards2.java b/generics/UnboundedWildcards2.java index 5e7d137b..dc20a66e 100644 --- a/generics/UnboundedWildcards2.java +++ b/generics/UnboundedWildcards2.java @@ -1,4 +1,4 @@ -//: generics/UnboundedWildcards2.java +// generics/UnboundedWildcards2.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -19,4 +19,5 @@ public class UnboundedWildcards2 { assign2(new HashMap<>()); assign3(new HashMap<>()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/Unconstrained.java b/generics/Unconstrained.java index b324a8e0..37066598 100644 --- a/generics/Unconstrained.java +++ b/generics/Unconstrained.java @@ -1,4 +1,4 @@ -//: generics/Unconstrained.java +// generics/Unconstrained.java // ©2015 MindView LLC: see Copyright.txt class Other {} @@ -11,6 +11,7 @@ public class Unconstrained { Other other = b.get(); b.f(); } -} /* Output: +} +/* Output: Other -*///:~ +*/ diff --git a/generics/UseList.java b/generics/UseList.java index ecf4e970..a82bef6d 100644 --- a/generics/UseList.java +++ b/generics/UseList.java @@ -1,8 +1,8 @@ -//: generics/UseList.java +// generics/UseList.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Will not compile) public class UseList { void f(List v) {} void f(List v) {} -} ///:~ +} diff --git a/generics/UseList2.java b/generics/UseList2.java index 208a0887..8da51991 100644 --- a/generics/UseList2.java +++ b/generics/UseList2.java @@ -1,8 +1,8 @@ -//: generics/UseList2.java +// generics/UseList2.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; public class UseList2 { void f1(List v) {} void f2(List v) {} -} ///:~ +} diff --git a/generics/WatercolorSets.java b/generics/WatercolorSets.java index 034f4495..01bb28e9 100644 --- a/generics/WatercolorSets.java +++ b/generics/WatercolorSets.java @@ -1,4 +1,4 @@ -//: generics/WatercolorSets.java +// generics/WatercolorSets.java // ©2015 MindView LLC: see Copyright.txt import generics.watercolors.*; import java.util.*; @@ -24,7 +24,8 @@ public class WatercolorSets { print("complement(set1, set2): " + complement(set1, set2)); } -} /* Output: +} +/* Output: set1: [BRILLIANT_RED, CRIMSON, MAGENTA, ROSE_MADDER, VIOLET, CERULEAN_BLUE_HUE, PHTHALO_BLUE, ULTRAMARINE, COBALT_BLUE_HUE, PERMANENT_GREEN, VIRIDIAN_HUE] @@ -46,4 +47,4 @@ RAW_UMBER, BURNT_SIENNA, BURNT_UMBER] complement(set1, set2): [VIOLET, YELLOW_OCHRE, RAW_UMBER, BURNT_UMBER, ROSE_MADDER, MAGENTA, SAP_GREEN, BURNT_SIENNA, BRILLIANT_RED, CRIMSON] -*///:~ +*/ diff --git a/generics/Wildcards.java b/generics/Wildcards.java index 2726fb86..5f1d6c44 100644 --- a/generics/Wildcards.java +++ b/generics/Wildcards.java @@ -1,4 +1,4 @@ -//: generics/Wildcards.java +// generics/Wildcards.java // ©2015 MindView LLC: see Copyright.txt // Exploring the meaning of wildcards. @@ -117,4 +117,5 @@ public class Wildcards { // wildSupertype(Holder,T) cannot be // applied to (Holder,Long) } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/coffee/Americano.java b/generics/coffee/Americano.java index acfabe91..956e6979 100644 --- a/generics/coffee/Americano.java +++ b/generics/coffee/Americano.java @@ -1,4 +1,4 @@ -//: generics/coffee/Americano.java +// generics/coffee/Americano.java // ©2015 MindView LLC: see Copyright.txt package generics.coffee; -public class Americano extends Coffee {} ///:~ +public class Americano extends Coffee {} diff --git a/generics/coffee/Breve.java b/generics/coffee/Breve.java index e558dabd..ada52209 100644 --- a/generics/coffee/Breve.java +++ b/generics/coffee/Breve.java @@ -1,4 +1,4 @@ -//: generics/coffee/Breve.java +// generics/coffee/Breve.java // ©2015 MindView LLC: see Copyright.txt package generics.coffee; -public class Breve extends Coffee {} ///:~ +public class Breve extends Coffee {} diff --git a/generics/coffee/Cappuccino.java b/generics/coffee/Cappuccino.java index 493bb565..d1af38bc 100644 --- a/generics/coffee/Cappuccino.java +++ b/generics/coffee/Cappuccino.java @@ -1,4 +1,4 @@ -//: generics/coffee/Cappuccino.java +// generics/coffee/Cappuccino.java // ©2015 MindView LLC: see Copyright.txt package generics.coffee; -public class Cappuccino extends Coffee {} ///:~ +public class Cappuccino extends Coffee {} diff --git a/generics/coffee/Coffee.java b/generics/coffee/Coffee.java index 2b623dfb..a4fe64dd 100644 --- a/generics/coffee/Coffee.java +++ b/generics/coffee/Coffee.java @@ -1,4 +1,4 @@ -//: generics/coffee/Coffee.java +// generics/coffee/Coffee.java // ©2015 MindView LLC: see Copyright.txt package generics.coffee; @@ -9,4 +9,4 @@ public class Coffee { public String toString() { return getClass().getSimpleName() + " " + id; } -} ///:~ +} diff --git a/generics/coffee/CoffeeGenerator.java b/generics/coffee/CoffeeGenerator.java index de6276b8..150e110a 100644 --- a/generics/coffee/CoffeeGenerator.java +++ b/generics/coffee/CoffeeGenerator.java @@ -1,4 +1,4 @@ -//: generics/coffee/CoffeeGenerator.java +// generics/coffee/CoffeeGenerator.java // ©2015 MindView LLC: see Copyright.txt // Generate different types of Coffee: package generics.coffee; @@ -50,7 +50,8 @@ implements Generator, Iterable { for(Coffee c : new CoffeeGenerator(5)) System.out.println(c); } -} /* Output: +} +/* Output: Americano 0 Latte 1 Americano 2 @@ -61,4 +62,4 @@ Americano 6 Latte 7 Cappuccino 8 Cappuccino 9 -*///:~ +*/ diff --git a/generics/coffee/Latte.java b/generics/coffee/Latte.java index 8f88bcad..76a7331c 100644 --- a/generics/coffee/Latte.java +++ b/generics/coffee/Latte.java @@ -1,4 +1,4 @@ -//: generics/coffee/Latte.java +// generics/coffee/Latte.java // ©2015 MindView LLC: see Copyright.txt package generics.coffee; -public class Latte extends Coffee {} ///:~ +public class Latte extends Coffee {} diff --git a/generics/coffee/Mocha.java b/generics/coffee/Mocha.java index 541d9186..b0ee7b0b 100644 --- a/generics/coffee/Mocha.java +++ b/generics/coffee/Mocha.java @@ -1,4 +1,4 @@ -//: generics/coffee/Mocha.java +// generics/coffee/Mocha.java // ©2015 MindView LLC: see Copyright.txt package generics.coffee; -public class Mocha extends Coffee {} ///:~ +public class Mocha extends Coffee {} diff --git a/generics/decorator/Decoration.java b/generics/decorator/Decoration.java index 9a633335..b22a509d 100644 --- a/generics/decorator/Decoration.java +++ b/generics/decorator/Decoration.java @@ -1,4 +1,4 @@ -//: generics/decorator/Decoration.java +// generics/decorator/Decoration.java // ©2015 MindView LLC: see Copyright.txt package generics.decorator; import java.util.*; @@ -45,4 +45,5 @@ public class Decoration { new TimeStamped(new Basic())); //! s2.getStamp(); // Not available } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/generics/watercolors/Watercolors.java b/generics/watercolors/Watercolors.java index f931bab5..aeaff9a4 100644 --- a/generics/watercolors/Watercolors.java +++ b/generics/watercolors/Watercolors.java @@ -1,4 +1,4 @@ -//: generics/watercolors/Watercolors.java +// generics/watercolors/Watercolors.java // ©2015 MindView LLC: see Copyright.txt package generics.watercolors; @@ -9,4 +9,4 @@ public enum Watercolors { COBALT_BLUE_HUE, PERMANENT_GREEN, VIRIDIAN_HUE, SAP_GREEN, YELLOW_OCHRE, BURNT_SIENNA, RAW_UMBER, BURNT_UMBER, PAYNES_GRAY, IVORY_BLACK -} ///:~ +} diff --git a/hiding/Cake.java b/hiding/Cake.java index 8f8110df..8087b3a1 100644 --- a/hiding/Cake.java +++ b/hiding/Cake.java @@ -1,4 +1,4 @@ -//: hiding/Cake.java +// hiding/Cake.java // ©2015 MindView LLC: see Copyright.txt // Accesses a class in a separate compilation unit. @@ -7,6 +7,7 @@ class Cake { Pie x = new Pie(); x.f(); } -} /* Output: +} +/* Output: Pie.f() -*///:~ +*/ diff --git a/hiding/ChocolateChip.java b/hiding/ChocolateChip.java index e34eef9f..c24a8cc7 100644 --- a/hiding/ChocolateChip.java +++ b/hiding/ChocolateChip.java @@ -1,4 +1,4 @@ -//: hiding/ChocolateChip.java +// hiding/ChocolateChip.java // ©2015 MindView LLC: see Copyright.txt // Can't use package-access member from another package. import hiding.dessert.*; @@ -14,7 +14,8 @@ public class ChocolateChip extends Cookie { ChocolateChip x = new ChocolateChip(); x.chomp(); } -} /* Output: +} +/* Output: Cookie constructor ChocolateChip constructor -*///:~ +*/ diff --git a/hiding/ChocolateChip2.java b/hiding/ChocolateChip2.java index 2b525d69..402c4f7f 100644 --- a/hiding/ChocolateChip2.java +++ b/hiding/ChocolateChip2.java @@ -1,4 +1,4 @@ -//: hiding/ChocolateChip2.java +// hiding/ChocolateChip2.java // ©2015 MindView LLC: see Copyright.txt import hiding.cookie2.*; @@ -11,8 +11,9 @@ public class ChocolateChip2 extends Cookie { ChocolateChip2 x = new ChocolateChip2(); x.chomp(); } -} /* Output: +} +/* Output: Cookie constructor ChocolateChip2 constructor bite -*///:~ +*/ diff --git a/hiding/Dinner.java b/hiding/Dinner.java index 76ddb16b..d69f8fea 100644 --- a/hiding/Dinner.java +++ b/hiding/Dinner.java @@ -1,4 +1,4 @@ -//: hiding/Dinner.java +// hiding/Dinner.java // ©2015 MindView LLC: see Copyright.txt // Uses the library. import hiding.dessert.*; @@ -8,6 +8,7 @@ public class Dinner { Cookie x = new Cookie(); //! x.bite(); // Can't access } -} /* Output: +} +/* Output: Cookie constructor -*///:~ +*/ diff --git a/hiding/FullQualification.java b/hiding/FullQualification.java index 4ca3c3cb..cd4eddc8 100644 --- a/hiding/FullQualification.java +++ b/hiding/FullQualification.java @@ -1,8 +1,9 @@ -//: hiding/FullQualification.java +// hiding/FullQualification.java // ©2015 MindView LLC: see Copyright.txt public class FullQualification { public static void main(String[] args) { java.util.ArrayList list = new java.util.ArrayList(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/hiding/IceCream.java b/hiding/IceCream.java index 9a116ea7..544c174d 100644 --- a/hiding/IceCream.java +++ b/hiding/IceCream.java @@ -1,4 +1,4 @@ -//: hiding/IceCream.java +// hiding/IceCream.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates "private" keyword. @@ -14,4 +14,5 @@ public class IceCream { //! Sundae x = new Sundae(); Sundae x = Sundae.makeASundae(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/hiding/ImportedMyClass.java b/hiding/ImportedMyClass.java index cf950b5f..078e4bed 100644 --- a/hiding/ImportedMyClass.java +++ b/hiding/ImportedMyClass.java @@ -1,4 +1,4 @@ -//: hiding/ImportedMyClass.java +// hiding/ImportedMyClass.java // ©2015 MindView LLC: see Copyright.txt import hiding.mypackage.*; @@ -6,4 +6,5 @@ public class ImportedMyClass { public static void main(String[] args) { MyClass m = new MyClass(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/hiding/LibTest.java b/hiding/LibTest.java index 97b9134a..0cb6b160 100644 --- a/hiding/LibTest.java +++ b/hiding/LibTest.java @@ -1,4 +1,4 @@ -//: hiding/LibTest.java +// hiding/LibTest.java // ©2015 MindView LLC: see Copyright.txt // Uses the library. import com.mindviewinc.simple.*; @@ -8,7 +8,8 @@ public class LibTest { Vector v = new Vector(); List l = new List(); } -} /* Output: +} +/* Output: com.mindviewinc.simple.Vector com.mindviewinc.simple.List -*///:~ +*/ diff --git a/hiding/Lunch.java b/hiding/Lunch.java index a231bd71..09fdf36a 100644 --- a/hiding/Lunch.java +++ b/hiding/Lunch.java @@ -1,4 +1,4 @@ -//: hiding/Lunch.java +// hiding/Lunch.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates class access specifiers. Make a class // effectively private with private constructors: @@ -34,4 +34,4 @@ public class Lunch { void testSingleton() { Soup2.access().f(); } -} ///:~ +} diff --git a/hiding/OrganizedByAccess.java b/hiding/OrganizedByAccess.java index a79cbe56..600b26d9 100644 --- a/hiding/OrganizedByAccess.java +++ b/hiding/OrganizedByAccess.java @@ -1,4 +1,4 @@ -//: hiding/OrganizedByAccess.java +// hiding/OrganizedByAccess.java // ©2015 MindView LLC: see Copyright.txt public class OrganizedByAccess { @@ -10,4 +10,4 @@ public class OrganizedByAccess { private void priv3() { /* ... */ } private int i; // ... -} ///:~ +} diff --git a/hiding/Pie.java b/hiding/Pie.java index 0b808c64..5389ff2d 100644 --- a/hiding/Pie.java +++ b/hiding/Pie.java @@ -1,7 +1,7 @@ -//: hiding/Pie.java +// hiding/Pie.java // ©2015 MindView LLC: see Copyright.txt // The other class. class Pie { void f() { System.out.println("Pie.f()"); } -} ///:~ +} diff --git a/hiding/PrintTest.java b/hiding/PrintTest.java index 7ddaba7b..e55f7e67 100644 --- a/hiding/PrintTest.java +++ b/hiding/PrintTest.java @@ -1,4 +1,4 @@ -//: hiding/PrintTest.java +// hiding/PrintTest.java // ©2015 MindView LLC: see Copyright.txt // Uses the static printing methods in Print.java. import static com.mindviewinc.util.Print.*; @@ -10,9 +10,10 @@ public class PrintTest { print(100L); print(3.14159); } -} /* Output: +} +/* Output: Available from now on! 100 100 3.14159 -*///:~ +*/ diff --git a/hiding/QualifiedMyClass.java b/hiding/QualifiedMyClass.java index b648671a..368f32f1 100644 --- a/hiding/QualifiedMyClass.java +++ b/hiding/QualifiedMyClass.java @@ -1,4 +1,4 @@ -//: hiding/QualifiedMyClass.java +// hiding/QualifiedMyClass.java // ©2015 MindView LLC: see Copyright.txt public class QualifiedMyClass { @@ -6,4 +6,5 @@ public class QualifiedMyClass { hiding.mypackage.MyClass m = new hiding.mypackage.MyClass(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/hiding/SingleImport.java b/hiding/SingleImport.java index 17e96a19..df9447e4 100644 --- a/hiding/SingleImport.java +++ b/hiding/SingleImport.java @@ -1,4 +1,4 @@ -//: hiding/SingleImport.java +// hiding/SingleImport.java // ©2015 MindView LLC: see Copyright.txt import java.util.ArrayList; @@ -6,4 +6,5 @@ public class SingleImport { public static void main(String[] args) { ArrayList list = new ArrayList(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/hiding/build.xml b/hiding/build.xml index 53530cc6..d08861f5 100644 --- a/hiding/build.xml +++ b/hiding/build.xml @@ -2,7 +2,7 @@ - + diff --git a/hiding/cookie2/Cookie.java b/hiding/cookie2/Cookie.java index 209b7003..cf80bc32 100644 --- a/hiding/cookie2/Cookie.java +++ b/hiding/cookie2/Cookie.java @@ -1,4 +1,4 @@ -//: hiding/cookie2/Cookie.java +// hiding/cookie2/Cookie.java // ©2015 MindView LLC: see Copyright.txt package hiding.cookie2; @@ -9,4 +9,4 @@ public class Cookie { protected void bite() { System.out.println("bite"); } -} ///:~ +} diff --git a/hiding/dessert/Cookie.java b/hiding/dessert/Cookie.java index 3781c257..c90968df 100644 --- a/hiding/dessert/Cookie.java +++ b/hiding/dessert/Cookie.java @@ -1,4 +1,4 @@ -//: hiding/dessert/Cookie.java +// hiding/dessert/Cookie.java // ©2015 MindView LLC: see Copyright.txt // Creates a library. package hiding.dessert; @@ -8,4 +8,4 @@ public class Cookie { System.out.println("Cookie constructor"); } void bite() { System.out.println("bite"); } -} ///:~ +} diff --git a/hiding/mypackage/MyClass.java b/hiding/mypackage/MyClass.java index 597b9475..e83d9de8 100644 --- a/hiding/mypackage/MyClass.java +++ b/hiding/mypackage/MyClass.java @@ -1,7 +1,7 @@ -//: hiding/mypackage/MyClass.java +// hiding/mypackage/MyClass.java // ©2015 MindView LLC: see Copyright.txt package hiding.mypackage; public class MyClass { // ... -} ///:~ +} diff --git a/housekeeping/Apricot.java b/housekeeping/Apricot.java index 761ef366..dcbe5eaf 100644 --- a/housekeeping/Apricot.java +++ b/housekeeping/Apricot.java @@ -1,6 +1,6 @@ -//: housekeeping/Apricot.java +// housekeeping/Apricot.java // ©2015 MindView LLC: see Copyright.txt public class Apricot { void pick() { /* ... */ } void pit() { pick(); /* ... */ } -} ///:~ +} diff --git a/housekeeping/ArrayClassObj.java b/housekeeping/ArrayClassObj.java index 53fa74c6..39250f5e 100644 --- a/housekeeping/ArrayClassObj.java +++ b/housekeeping/ArrayClassObj.java @@ -1,4 +1,4 @@ -//: housekeeping/ArrayClassObj.java +// housekeeping/ArrayClassObj.java // ©2015 MindView LLC: see Copyright.txt // Creating an array of nonprimitive objects. import java.util.*; @@ -13,8 +13,9 @@ public class ArrayClassObj { a[i] = rand.nextInt(500); // Autoboxing print(Arrays.toString(a)); } -} /* Output: +} +/* Output: length of a = 18 [55, 193, 361, 461, 429, 368, 200, 22, 207, 288, 128, 51, 89, 309, 278, 498, 361, 20] -*///:~ +*/ diff --git a/housekeeping/ArrayInit.java b/housekeeping/ArrayInit.java index 340ab882..ad96d5bf 100644 --- a/housekeeping/ArrayInit.java +++ b/housekeeping/ArrayInit.java @@ -1,4 +1,4 @@ -//: housekeeping/ArrayInit.java +// housekeeping/ArrayInit.java // ©2015 MindView LLC: see Copyright.txt // Array initialization. import java.util.*; @@ -16,7 +16,8 @@ public class ArrayInit { System.out.println(Arrays.toString(a)); System.out.println(Arrays.toString(b)); } -} /* Output: +} +/* Output: [1, 2, 3] [1, 2, 3] -*///:~ +*/ diff --git a/housekeeping/ArrayNew.java b/housekeeping/ArrayNew.java index fa97e5fb..b418a992 100644 --- a/housekeeping/ArrayNew.java +++ b/housekeeping/ArrayNew.java @@ -1,4 +1,4 @@ -//: housekeeping/ArrayNew.java +// housekeeping/ArrayNew.java // ©2015 MindView LLC: see Copyright.txt // Creating arrays with new. import java.util.*; @@ -12,7 +12,8 @@ public class ArrayNew { print("length of a = " + a.length); print(Arrays.toString(a)); } -} /* Output: +} +/* Output: length of a = 18 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -*///:~ +*/ diff --git a/housekeeping/ArraysOfPrimitives.java b/housekeeping/ArraysOfPrimitives.java index eb4265e4..0bf865e5 100644 --- a/housekeeping/ArraysOfPrimitives.java +++ b/housekeeping/ArraysOfPrimitives.java @@ -1,4 +1,4 @@ -//: housekeeping/ArraysOfPrimitives.java +// housekeeping/ArraysOfPrimitives.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -12,10 +12,11 @@ public class ArraysOfPrimitives { for(int i = 0; i < a1.length; i++) print("a1[" + i + "] = " + a1[i]); } -} /* Output: +} +/* Output: a1[0] = 2 a1[1] = 3 a1[2] = 4 a1[3] = 5 a1[4] = 6 -*///:~ +*/ diff --git a/housekeeping/AutoboxingVarargs.java b/housekeeping/AutoboxingVarargs.java index b02d6afd..bcc9e1a2 100644 --- a/housekeeping/AutoboxingVarargs.java +++ b/housekeeping/AutoboxingVarargs.java @@ -1,4 +1,4 @@ -//: housekeeping/AutoboxingVarargs.java +// housekeeping/AutoboxingVarargs.java // ©2015 MindView LLC: see Copyright.txt public class AutoboxingVarargs { @@ -12,8 +12,9 @@ public class AutoboxingVarargs { f(4, 5, 6, 7, 8, 9); f(10, 11, 12); } -} /* Output: +} +/* Output: 1 2 4 5 6 7 8 9 10 11 12 -*///:~ +*/ diff --git a/housekeeping/BananaPeel.java b/housekeeping/BananaPeel.java index cdbfd1a6..a88a5aa1 100644 --- a/housekeeping/BananaPeel.java +++ b/housekeeping/BananaPeel.java @@ -1,4 +1,4 @@ -//: housekeeping/BananaPeel.java +// housekeeping/BananaPeel.java // ©2015 MindView LLC: see Copyright.txt class Banana { void peel(int i) { /* ... */ } } @@ -10,4 +10,5 @@ public class BananaPeel { a.peel(1); b.peel(2); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/housekeeping/Burrito.java b/housekeeping/Burrito.java index 52603458..7ad2f96a 100644 --- a/housekeeping/Burrito.java +++ b/housekeeping/Burrito.java @@ -1,4 +1,4 @@ -//: housekeeping/Burrito.java +// housekeeping/Burrito.java // ©2015 MindView LLC: see Copyright.txt public class Burrito { @@ -26,8 +26,9 @@ public class Burrito { greenChile.describe(); jalapeno.describe(); } -} /* Output: +} +/* Output: This burrito is not spicy at all. This burrito is a little hot. This burrito is maybe too hot. -*///:~ +*/ diff --git a/housekeeping/Counter.java b/housekeeping/Counter.java index 400a3c9b..c4c104ac 100644 --- a/housekeeping/Counter.java +++ b/housekeeping/Counter.java @@ -1,7 +1,7 @@ -//: housekeeping/Counter.java +// housekeeping/Counter.java // ©2015 MindView LLC: see Copyright.txt public class Counter { int i; Counter() { i = 7; } // ... -} ///:~ +} diff --git a/housekeeping/DefaultConstructor.java b/housekeeping/DefaultConstructor.java index b7dca61e..bd2400e1 100644 --- a/housekeeping/DefaultConstructor.java +++ b/housekeeping/DefaultConstructor.java @@ -1,4 +1,4 @@ -//: housekeeping/DefaultConstructor.java +// housekeeping/DefaultConstructor.java // ©2015 MindView LLC: see Copyright.txt class Bird {} @@ -7,4 +7,5 @@ public class DefaultConstructor { public static void main(String[] args) { Bird b = new Bird(); // Default! } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/housekeeping/Demotion.java b/housekeeping/Demotion.java index b01b20c8..7bd021265 100644 --- a/housekeeping/Demotion.java +++ b/housekeeping/Demotion.java @@ -1,4 +1,4 @@ -//: housekeeping/Demotion.java +// housekeeping/Demotion.java // ©2015 MindView LLC: see Copyright.txt // Demotion of primitives and overloading. import static com.mindviewinc.util.Print.*; @@ -49,7 +49,8 @@ public class Demotion { Demotion p = new Demotion(); p.testDouble(); } -} /* Output: +} +/* Output: double argument: f1(double) f2(float) @@ -58,4 +59,4 @@ f4(int) f5(short) f6(byte) f7(char) -*///:~ +*/ diff --git a/housekeeping/DynamicArray.java b/housekeeping/DynamicArray.java index e9c277b9..eb00511c 100644 --- a/housekeeping/DynamicArray.java +++ b/housekeeping/DynamicArray.java @@ -1,4 +1,4 @@ -//: housekeeping/DynamicArray.java +// housekeeping/DynamicArray.java // ©2015 MindView LLC: see Copyright.txt // Array initialization. @@ -13,6 +13,7 @@ class Other { for(String s : args) System.out.print(s + " "); } -} /* Output: +} +/* Output: fiddle de dum -*///:~ +*/ diff --git a/housekeeping/EnumOrder.java b/housekeeping/EnumOrder.java index de185d34..87d683ee 100644 --- a/housekeeping/EnumOrder.java +++ b/housekeeping/EnumOrder.java @@ -1,4 +1,4 @@ -//: housekeeping/EnumOrder.java +// housekeeping/EnumOrder.java // ©2015 MindView LLC: see Copyright.txt public class EnumOrder { @@ -6,10 +6,11 @@ public class EnumOrder { for(Spiciness s : Spiciness.values()) System.out.println(s + ", ordinal " + s.ordinal()); } -} /* Output: +} +/* Output: NOT, ordinal 0 MILD, ordinal 1 MEDIUM, ordinal 2 HOT, ordinal 3 FLAMING, ordinal 4 -*///:~ +*/ diff --git a/housekeeping/ExplicitStatic.java b/housekeeping/ExplicitStatic.java index ccf2b9e0..603587b6 100644 --- a/housekeeping/ExplicitStatic.java +++ b/housekeeping/ExplicitStatic.java @@ -1,4 +1,4 @@ -//: housekeeping/ExplicitStatic.java +// housekeeping/ExplicitStatic.java // ©2015 MindView LLC: see Copyright.txt // Explicit static initialization with the "static" clause. import static com.mindviewinc.util.Print.*; @@ -31,9 +31,10 @@ public class ExplicitStatic { } // static Cups cups1 = new Cups(); // (2) // static Cups cups2 = new Cups(); // (2) -} /* Output: +} +/* Output: Inside main() Cup(1) Cup(2) f(99) -*///:~ +*/ diff --git a/housekeeping/Flower.java b/housekeeping/Flower.java index c7c7f72e..ce1b3501 100644 --- a/housekeeping/Flower.java +++ b/housekeeping/Flower.java @@ -1,4 +1,4 @@ -//: housekeeping/Flower.java +// housekeeping/Flower.java // ©2015 MindView LLC: see Copyright.txt // Calling constructors with "this" import static com.mindviewinc.util.Print.*; @@ -33,9 +33,10 @@ public class Flower { Flower x = new Flower(); x.printPetalCount(); } -} /* Output: +} +/* Output: Constructor w/ int arg only, petalCount= 47 String & int args default constructor (no args) petalCount = 47 s = hi -*///:~ +*/ diff --git a/housekeeping/InitialValues.java b/housekeeping/InitialValues.java index c37aaf63..4211305e 100644 --- a/housekeeping/InitialValues.java +++ b/housekeeping/InitialValues.java @@ -1,4 +1,4 @@ -//: housekeeping/InitialValues.java +// housekeeping/InitialValues.java // ©2015 MindView LLC: see Copyright.txt // Shows default initial values. import static com.mindviewinc.util.Print.*; @@ -32,7 +32,8 @@ public class InitialValues { new InitialValues().printInitialValues(); */ } -} /* Output: +} +/* Output: Data type Initial value boolean false char [NUL] @@ -43,4 +44,4 @@ long 0 float 0.0 double 0.0 reference null -*///:~ +*/ diff --git a/housekeeping/InitialValues2.java b/housekeeping/InitialValues2.java index 0bd596f4..9c80cf2c 100644 --- a/housekeeping/InitialValues2.java +++ b/housekeeping/InitialValues2.java @@ -1,4 +1,4 @@ -//: housekeeping/InitialValues2.java +// housekeeping/InitialValues2.java // ©2015 MindView LLC: see Copyright.txt // Providing explicit initial values. @@ -11,4 +11,4 @@ public class InitialValues2 { long lng = 1; float f = 3.14f; double d = 3.14159; -} ///:~ +} diff --git a/housekeeping/Leaf.java b/housekeeping/Leaf.java index 671dd61f..bc9baa65 100644 --- a/housekeeping/Leaf.java +++ b/housekeeping/Leaf.java @@ -1,4 +1,4 @@ -//: housekeeping/Leaf.java +// housekeeping/Leaf.java // ©2015 MindView LLC: see Copyright.txt // Simple use of the "this" keyword. @@ -15,6 +15,7 @@ public class Leaf { Leaf x = new Leaf(); x.increment().increment().increment().print(); } -} /* Output: +} +/* Output: i = 3 -*///:~ +*/ diff --git a/housekeeping/Measurement.java b/housekeeping/Measurement.java index 9b66c08c..9dfd0f29 100644 --- a/housekeeping/Measurement.java +++ b/housekeeping/Measurement.java @@ -1,8 +1,8 @@ -//: housekeeping/Measurement.java +// housekeeping/Measurement.java // ©2015 MindView LLC: see Copyright.txt class Depth {} public class Measurement { Depth d = new Depth(); // ... -} ///:~ +} diff --git a/housekeeping/MethodInit.java b/housekeeping/MethodInit.java index 93deec5b..21c6aa58 100644 --- a/housekeeping/MethodInit.java +++ b/housekeeping/MethodInit.java @@ -1,6 +1,6 @@ -//: housekeeping/MethodInit.java +// housekeeping/MethodInit.java // ©2015 MindView LLC: see Copyright.txt public class MethodInit { int i = f(); int f() { return 11; } -} ///:~ +} diff --git a/housekeeping/MethodInit2.java b/housekeeping/MethodInit2.java index 75cf7867..7b81b568 100644 --- a/housekeeping/MethodInit2.java +++ b/housekeeping/MethodInit2.java @@ -1,8 +1,8 @@ -//: housekeeping/MethodInit2.java +// housekeeping/MethodInit2.java // ©2015 MindView LLC: see Copyright.txt public class MethodInit2 { int i = f(); int j = g(i); int f() { return 11; } int g(int n) { return n * 10; } -} ///:~ +} diff --git a/housekeeping/MethodInit3.java b/housekeeping/MethodInit3.java index 7e321f98..cae3ff24 100644 --- a/housekeeping/MethodInit3.java +++ b/housekeeping/MethodInit3.java @@ -1,8 +1,8 @@ -//: housekeeping/MethodInit3.java +// housekeeping/MethodInit3.java // ©2015 MindView LLC: see Copyright.txt public class MethodInit3 { //! int j = g(i); // Illegal forward reference int i = f(); int f() { return 11; } int g(int n) { return n * 10; } -} ///:~ +} diff --git a/housekeeping/Mugs.java b/housekeeping/Mugs.java index aa1dc9c9..cea0b0be 100644 --- a/housekeeping/Mugs.java +++ b/housekeeping/Mugs.java @@ -1,4 +1,4 @@ -//: housekeeping/Mugs.java +// housekeeping/Mugs.java // ©2015 MindView LLC: see Copyright.txt // Java "Instance Initialization." import static com.mindviewinc.util.Print.*; @@ -33,7 +33,8 @@ public class Mugs { new Mugs(1); print("new Mugs(1) completed"); } -} /* Output: +} +/* Output: Inside main() Mug(1) Mug(2) @@ -45,4 +46,4 @@ Mug(2) mug1 & mug2 initialized Mugs(int) new Mugs(1) completed -*///:~ +*/ diff --git a/housekeeping/NewVarArgs.java b/housekeeping/NewVarArgs.java index 94d5ce34..e52775e6 100644 --- a/housekeeping/NewVarArgs.java +++ b/housekeeping/NewVarArgs.java @@ -1,4 +1,4 @@ -//: housekeeping/NewVarArgs.java +// housekeeping/NewVarArgs.java // ©2015 MindView LLC: see Copyright.txt // Using array syntax to create variable argument lists. @@ -18,10 +18,11 @@ public class NewVarArgs { printArray((Object[])new Integer[]{ 1, 2, 3, 4 }); printArray(); // Empty list is OK } -} /* Output: +} +/* Output: 47 3.14 11.11 47 3.14 11.11 one two three A@19e0bfd A@139a55 A@1db9742 1 2 3 4 -*///:~ +*/ diff --git a/housekeeping/NoSynthesis.java b/housekeeping/NoSynthesis.java index 0acc9d94..85b37f18 100644 --- a/housekeeping/NoSynthesis.java +++ b/housekeeping/NoSynthesis.java @@ -1,4 +1,4 @@ -//: housekeeping/NoSynthesis.java +// housekeeping/NoSynthesis.java // ©2015 MindView LLC: see Copyright.txt class Bird2 { @@ -12,4 +12,5 @@ public class NoSynthesis { Bird2 b2 = new Bird2(1); Bird2 b3 = new Bird2(1.0); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/housekeeping/OptionalTrailingArguments.java b/housekeeping/OptionalTrailingArguments.java index 48d85d20..b00dd548 100644 --- a/housekeeping/OptionalTrailingArguments.java +++ b/housekeeping/OptionalTrailingArguments.java @@ -1,4 +1,4 @@ -//: housekeeping/OptionalTrailingArguments.java +// housekeeping/OptionalTrailingArguments.java // ©2015 MindView LLC: see Copyright.txt public class OptionalTrailingArguments { @@ -13,8 +13,9 @@ public class OptionalTrailingArguments { f(2, "two", "three"); f(0); } -} /* Output: +} +/* Output: required: 1 one required: 2 two three required: 0 -*///:~ +*/ diff --git a/housekeeping/OrderOfInitialization.java b/housekeeping/OrderOfInitialization.java index 60e3f0d9..68405f3d 100644 --- a/housekeeping/OrderOfInitialization.java +++ b/housekeeping/OrderOfInitialization.java @@ -1,4 +1,4 @@ -//: housekeeping/OrderOfInitialization.java +// housekeeping/OrderOfInitialization.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates initialization order. import static com.mindviewinc.util.Print.*; @@ -26,11 +26,12 @@ public class OrderOfInitialization { House h = new House(); h.f(); // Shows that construction is done } -} /* Output: +} +/* Output: Window(1) Window(2) Window(3) House() Window(33) f() -*///:~ +*/ diff --git a/housekeeping/Overloading.java b/housekeeping/Overloading.java index 7adfd8a1..bd8458eb 100644 --- a/housekeeping/Overloading.java +++ b/housekeeping/Overloading.java @@ -1,4 +1,4 @@ -//: housekeeping/Overloading.java +// housekeeping/Overloading.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of both constructor // and ordinary method overloading. @@ -33,7 +33,8 @@ public class Overloading { // Overloaded constructor: new Tree(); } -} /* Output: +} +/* Output: Creating new Tree that is 0 feet tall Tree is 0 feet tall overloaded method: Tree is 0 feet tall @@ -50,4 +51,4 @@ Creating new Tree that is 4 feet tall Tree is 4 feet tall overloaded method: Tree is 4 feet tall Planting a seedling -*///:~ +*/ diff --git a/housekeeping/OverloadingOrder.java b/housekeeping/OverloadingOrder.java index 3c1dace3..96babb3b 100644 --- a/housekeeping/OverloadingOrder.java +++ b/housekeeping/OverloadingOrder.java @@ -1,4 +1,4 @@ -//: housekeeping/OverloadingOrder.java +// housekeeping/OverloadingOrder.java // ©2015 MindView LLC: see Copyright.txt // Overloading based on the order of the arguments. import static com.mindviewinc.util.Print.*; @@ -14,7 +14,8 @@ public class OverloadingOrder { f("String first", 11); f(99, "Int first"); } -} /* Output: +} +/* Output: String: String first, int: 11 int: 99, String: Int first -*///:~ +*/ diff --git a/housekeeping/OverloadingVarargs.java b/housekeeping/OverloadingVarargs.java index bc963d5b..013de4f7 100644 --- a/housekeeping/OverloadingVarargs.java +++ b/housekeeping/OverloadingVarargs.java @@ -1,4 +1,4 @@ -//: housekeeping/OverloadingVarargs.java +// housekeeping/OverloadingVarargs.java // ©2015 MindView LLC: see Copyright.txt public class OverloadingVarargs { @@ -25,10 +25,11 @@ public class OverloadingVarargs { f(0L); //! f(); // Won't compile -- ambiguous } -} /* Output: +} +/* Output: first a b c second 1 second 2 1 second 0 third -*///:~ +*/ diff --git a/housekeeping/OverloadingVarargs2.java b/housekeeping/OverloadingVarargs2.java index 608b702c..28b36cf3 100644 --- a/housekeeping/OverloadingVarargs2.java +++ b/housekeeping/OverloadingVarargs2.java @@ -1,4 +1,4 @@ -//: housekeeping/OverloadingVarargs2.java +// housekeeping/OverloadingVarargs2.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Won't compile) @@ -13,4 +13,5 @@ public class OverloadingVarargs2 { f(1, 'a'); f('a', 'b'); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/housekeeping/OverloadingVarargs3.java b/housekeeping/OverloadingVarargs3.java index 016c7e53..8ade58db 100644 --- a/housekeeping/OverloadingVarargs3.java +++ b/housekeeping/OverloadingVarargs3.java @@ -1,4 +1,4 @@ -//: housekeeping/OverloadingVarargs3.java +// housekeeping/OverloadingVarargs3.java // ©2015 MindView LLC: see Copyright.txt public class OverloadingVarargs3 { @@ -12,7 +12,8 @@ public class OverloadingVarargs3 { f(1, 'a'); f('a', 'b'); } -} /* Output: +} +/* Output: first second -*///:~ +*/ diff --git a/housekeeping/PassingThis.java b/housekeeping/PassingThis.java index a01fa6cd..f9e52cc1 100644 --- a/housekeeping/PassingThis.java +++ b/housekeeping/PassingThis.java @@ -1,4 +1,4 @@ -//: housekeeping/PassingThis.java +// housekeeping/PassingThis.java // ©2015 MindView LLC: see Copyright.txt class Person { @@ -23,6 +23,7 @@ public class PassingThis { public static void main(String[] args) { new Person().eat(new Apple()); } -} /* Output: +} +/* Output: Yummy -*///:~ +*/ diff --git a/housekeeping/PrimitiveOverloading.java b/housekeeping/PrimitiveOverloading.java index 567dd7f9..633e3827 100644 --- a/housekeeping/PrimitiveOverloading.java +++ b/housekeeping/PrimitiveOverloading.java @@ -1,4 +1,4 @@ -//: housekeeping/PrimitiveOverloading.java +// housekeeping/PrimitiveOverloading.java // ©2015 MindView LLC: see Copyright.txt // Promotion of primitives and overloading. import static com.mindviewinc.util.Print.*; @@ -90,7 +90,8 @@ public class PrimitiveOverloading { p.testFloat(); p.testDouble(); } -} /* Output: +} +/* Output: 5: f1(int) f2(int) f3(int) f4(int) f5(long) f6(float) f7(double) char: f1(char) f2(int) f3(int) f4(int) f5(long) f6(float) @@ -107,4 +108,4 @@ float: f1(float) f2(float) f3(float) f4(float) f5(float) f6(float) f7(double) double: f1(double) f2(double) f3(double) f4(double) f5(double) f6(double) f7(double) -*///:~ +*/ diff --git a/housekeeping/SimpleConstructor.java b/housekeeping/SimpleConstructor.java index 9892dc04..8b91459b 100644 --- a/housekeeping/SimpleConstructor.java +++ b/housekeeping/SimpleConstructor.java @@ -1,4 +1,4 @@ -//: housekeeping/SimpleConstructor.java +// housekeeping/SimpleConstructor.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of a simple constructor. @@ -13,6 +13,7 @@ public class SimpleConstructor { for(int i = 0; i < 10; i++) new Rock(); } -} /* Output: +} +/* Output: Rock Rock Rock Rock Rock Rock Rock Rock Rock Rock -*///:~ +*/ diff --git a/housekeeping/SimpleConstructor2.java b/housekeeping/SimpleConstructor2.java index 790fd97b..49dc7131 100644 --- a/housekeeping/SimpleConstructor2.java +++ b/housekeeping/SimpleConstructor2.java @@ -1,4 +1,4 @@ -//: housekeeping/SimpleConstructor2.java +// housekeeping/SimpleConstructor2.java // ©2015 MindView LLC: see Copyright.txt // Constructors can have arguments. @@ -13,6 +13,7 @@ public class SimpleConstructor2 { for(int i = 0; i < 8; i++) new Rock2(i); } -} /* Output: +} +/* Output: Rock 0 Rock 1 Rock 2 Rock 3 Rock 4 Rock 5 Rock 6 Rock 7 -*///:~ +*/ diff --git a/housekeeping/SimpleEnumUse.java b/housekeeping/SimpleEnumUse.java index eed8a00e..04effc08 100644 --- a/housekeeping/SimpleEnumUse.java +++ b/housekeeping/SimpleEnumUse.java @@ -1,4 +1,4 @@ -//: housekeeping/SimpleEnumUse.java +// housekeeping/SimpleEnumUse.java // ©2015 MindView LLC: see Copyright.txt public class SimpleEnumUse { @@ -6,6 +6,7 @@ public class SimpleEnumUse { Spiciness howHot = Spiciness.MEDIUM; System.out.println(howHot); } -} /* Output: +} +/* Output: MEDIUM -*///:~ +*/ diff --git a/housekeeping/Spiciness.java b/housekeeping/Spiciness.java index d4905355..086e1a77 100644 --- a/housekeeping/Spiciness.java +++ b/housekeeping/Spiciness.java @@ -1,6 +1,6 @@ -//: housekeeping/Spiciness.java +// housekeeping/Spiciness.java // ©2015 MindView LLC: see Copyright.txt public enum Spiciness { NOT, MILD, MEDIUM, HOT, FLAMING -} ///:~ +} diff --git a/housekeeping/Spoon.java b/housekeeping/Spoon.java index 7332da03..133b0520 100644 --- a/housekeeping/Spoon.java +++ b/housekeeping/Spoon.java @@ -1,8 +1,8 @@ -//: housekeeping/Spoon.java +// housekeeping/Spoon.java // ©2015 MindView LLC: see Copyright.txt public class Spoon { static int i; static { i = 47; } -} ///:~ +} diff --git a/housekeeping/StaticInitialization.java b/housekeeping/StaticInitialization.java index 7acf5c58..4d0490bd 100644 --- a/housekeeping/StaticInitialization.java +++ b/housekeeping/StaticInitialization.java @@ -1,4 +1,4 @@ -//: housekeeping/StaticInitialization.java +// housekeeping/StaticInitialization.java // ©2015 MindView LLC: see Copyright.txt // Specifying initial values in a class definition. import static com.mindviewinc.util.Print.*; @@ -48,7 +48,8 @@ public class StaticInitialization { } static Table table = new Table(); static Cupboard cupboard = new Cupboard(); -} /* Output: +} +/* Output: Bowl(1) Bowl(2) Table() @@ -68,4 +69,4 @@ Cupboard() f1(2) f2(1) f3(1) -*///:~ +*/ diff --git a/housekeeping/TerminationCondition.java b/housekeeping/TerminationCondition.java index 4791b2ee..b777193a 100644 --- a/housekeeping/TerminationCondition.java +++ b/housekeeping/TerminationCondition.java @@ -1,4 +1,4 @@ -//: housekeeping/TerminationCondition.java +// housekeeping/TerminationCondition.java // ©2015 MindView LLC: see Copyright.txt // Using finalize() to detect an object that // hasn't been properly cleaned up. @@ -32,6 +32,7 @@ public class TerminationCondition { System.gc(); new Sleep(1); // Delay } -} /* Output: +} +/* Output: Error: checked out -*///:~ +*/ diff --git a/housekeeping/VarArgs.java b/housekeeping/VarArgs.java index 7a0b2240..e44e88c0 100644 --- a/housekeeping/VarArgs.java +++ b/housekeeping/VarArgs.java @@ -1,4 +1,4 @@ -//: housekeeping/VarArgs.java +// housekeeping/VarArgs.java // ©2015 MindView LLC: see Copyright.txt // Using array syntax to create variable argument lists. @@ -16,8 +16,9 @@ public class VarArgs { printArray(new Object[]{"one", "two", "three" }); printArray(new Object[]{new A(), new A(), new A()}); } -} /* Output: +} +/* Output: 47 3.14 11.11 one two three A@19e0bfd A@139a55 A@1db9742 -*///:~ +*/ diff --git a/housekeeping/VarargType.java b/housekeeping/VarargType.java index d539d46f..8ab5b70f 100644 --- a/housekeeping/VarargType.java +++ b/housekeeping/VarargType.java @@ -1,4 +1,4 @@ -//: housekeeping/VarargType.java +// housekeeping/VarargType.java // ©2015 MindView LLC: see Copyright.txt public class VarargType { @@ -17,10 +17,11 @@ public class VarargType { g(); System.out.println("int[]: " + new int[0].getClass()); } -} /* Output: +} +/* Output: class [Ljava.lang.Character; length 1 class [Ljava.lang.Character; length 0 class [I length 1 class [I length 0 int[]: class [I -*///:~ +*/ diff --git a/innerclasses/AnonymousConstructor.java b/innerclasses/AnonymousConstructor.java index 1f380572..bfa0ffae 100644 --- a/innerclasses/AnonymousConstructor.java +++ b/innerclasses/AnonymousConstructor.java @@ -1,4 +1,4 @@ -//: innerclasses/AnonymousConstructor.java +// innerclasses/AnonymousConstructor.java // ©2015 MindView LLC: see Copyright.txt // Creating a constructor for an anonymous inner class. import static com.mindviewinc.util.Print.*; @@ -24,8 +24,9 @@ public class AnonymousConstructor { Base base = getBase(47); base.f(); } -} /* Output: +} +/* Output: Base constructor, i = 47 Inside instance initializer In anonymous f() -*///:~ +*/ diff --git a/innerclasses/BigEgg.java b/innerclasses/BigEgg.java index 9e75976d..5f1e64a3 100644 --- a/innerclasses/BigEgg.java +++ b/innerclasses/BigEgg.java @@ -1,4 +1,4 @@ -//: innerclasses/BigEgg.java +// innerclasses/BigEgg.java // ©2015 MindView LLC: see Copyright.txt // An inner class cannot be overriden like a method. import static com.mindviewinc.util.Print.*; @@ -21,7 +21,8 @@ public class BigEgg extends Egg { public static void main(String[] args) { new BigEgg(); } -} /* Output: +} +/* Output: New Egg() Egg.Yolk() -*///:~ +*/ diff --git a/innerclasses/BigEgg2.java b/innerclasses/BigEgg2.java index 5e495b49..545236a9 100644 --- a/innerclasses/BigEgg2.java +++ b/innerclasses/BigEgg2.java @@ -1,4 +1,4 @@ -//: innerclasses/BigEgg2.java +// innerclasses/BigEgg2.java // ©2015 MindView LLC: see Copyright.txt // Proper inheritance of an inner class. import static com.mindviewinc.util.Print.*; @@ -25,10 +25,11 @@ public class BigEgg2 extends Egg2 { Egg2 e2 = new BigEgg2(); e2.g(); } -} /* Output: +} +/* Output: Egg2.Yolk() New Egg2() Egg2.Yolk() BigEgg2.Yolk() BigEgg2.Yolk.f() -*///:~ +*/ diff --git a/innerclasses/Callbacks.java b/innerclasses/Callbacks.java index 9b7e8ffe..140e1466 100644 --- a/innerclasses/Callbacks.java +++ b/innerclasses/Callbacks.java @@ -1,4 +1,4 @@ -//: innerclasses/Callbacks.java +// innerclasses/Callbacks.java // ©2015 MindView LLC: see Copyright.txt // Using inner classes for callbacks package innerclasses; @@ -64,7 +64,8 @@ public class Callbacks { caller2.go(); caller2.go(); } -} /* Output: +} +/* Output: Other operation 1 1 @@ -73,4 +74,4 @@ Other operation 2 Other operation 3 -*///:~ +*/ diff --git a/innerclasses/ClassInInterface.java b/innerclasses/ClassInInterface.java index 07b44983..3d0b42e6 100644 --- a/innerclasses/ClassInInterface.java +++ b/innerclasses/ClassInInterface.java @@ -1,4 +1,4 @@ -//: innerclasses/ClassInInterface.java +// innerclasses/ClassInInterface.java // ©2015 MindView LLC: see Copyright.txt // {main: ClassInInterface$Test} @@ -13,6 +13,7 @@ public interface ClassInInterface { new Test().howdy(); } } -} /* Output: +} +/* Output: Howdy! -*///:~ +*/ diff --git a/innerclasses/Contents.java b/innerclasses/Contents.java index 8f279867..f514df87 100644 --- a/innerclasses/Contents.java +++ b/innerclasses/Contents.java @@ -1,5 +1,5 @@ -//: innerclasses/Contents.java +// innerclasses/Contents.java // ©2015 MindView LLC: see Copyright.txt public interface Contents { int value(); -} ///:~ +} diff --git a/innerclasses/CtorReference.java b/innerclasses/CtorReference.java index fdfcf234..14e4646c 100644 --- a/innerclasses/CtorReference.java +++ b/innerclasses/CtorReference.java @@ -1,4 +1,4 @@ -//: innerclasses/CtorReference.java +// innerclasses/CtorReference.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates java.util.function import java.util.function.*; @@ -27,8 +27,9 @@ public class CtorReference { CtorReference::new; CtorReference r2 = cr2.apply(1, 2.0); } -} /* Output: +} +/* Output: Inside CtorReference() Inside CtorReference(i) Inside CtorReference(i, d) -*///:~ +*/ diff --git a/innerclasses/Destination.java b/innerclasses/Destination.java index b364e970..a82cfc0d 100644 --- a/innerclasses/Destination.java +++ b/innerclasses/Destination.java @@ -1,5 +1,5 @@ -//: innerclasses/Destination.java +// innerclasses/Destination.java // ©2015 MindView LLC: see Copyright.txt public interface Destination { String readLabel(); -} ///:~ +} diff --git a/innerclasses/DotNew.java b/innerclasses/DotNew.java index 0261d126..1e300445 100644 --- a/innerclasses/DotNew.java +++ b/innerclasses/DotNew.java @@ -1,4 +1,4 @@ -//: innerclasses/DotNew.java +// innerclasses/DotNew.java // ©2015 MindView LLC: see Copyright.txt // Creating an inner class directly using the .new syntax. @@ -8,4 +8,5 @@ public class DotNew { DotNew dn = new DotNew(); DotNew.Inner dni = dn.new Inner(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/DotThis.java b/innerclasses/DotThis.java index 6c88ae75..ecec9d76 100644 --- a/innerclasses/DotThis.java +++ b/innerclasses/DotThis.java @@ -1,4 +1,4 @@ -//: innerclasses/DotThis.java +// innerclasses/DotThis.java // ©2015 MindView LLC: see Copyright.txt // Qualifying access to the outer-class object. @@ -16,6 +16,7 @@ public class DotThis { DotThis.Inner dti = dt.inner(); dti.outer().f(); } -} /* Output: +} +/* Output: DotThis.f() -*///:~ +*/ diff --git a/innerclasses/Factories.java b/innerclasses/Factories.java index 9bc16fb0..0638e1ed 100644 --- a/innerclasses/Factories.java +++ b/innerclasses/Factories.java @@ -1,4 +1,4 @@ -//: innerclasses/Factories.java +// innerclasses/Factories.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -53,11 +53,12 @@ public class Factories { serviceConsumer(Implementation2.factory); serviceConsumer(Implementation3.factory); } -} /* Output: +} +/* Output: Implementation1 method1 Implementation1 method2 Implementation2 method1 Implementation2 method2 Implementation3 method1 Implementation3 method2 -*///:~ +*/ diff --git a/innerclasses/Games.java b/innerclasses/Games.java index 94027dc6..b7c1bd58 100644 --- a/innerclasses/Games.java +++ b/innerclasses/Games.java @@ -1,4 +1,4 @@ -//: innerclasses/Games.java +// innerclasses/Games.java // ©2015 MindView LLC: see Copyright.txt // Using anonymous inner classes with the Game framework. import static com.mindviewinc.util.Print.*; @@ -55,7 +55,8 @@ public class Games { playGame(Chess.factory); playGame(TicTacToe.factory); } -} /* Output: +} +/* Output: Checkers move 0 Checkers move 1 Checkers move 2 @@ -67,4 +68,4 @@ TicTacToe move 0 TicTacToe move 1 TicTacToe move 2 TicTacToe move 3 -*///:~ +*/ diff --git a/innerclasses/GreenhouseController.java b/innerclasses/GreenhouseController.java index 127cc319..69d4d98e 100644 --- a/innerclasses/GreenhouseController.java +++ b/innerclasses/GreenhouseController.java @@ -1,4 +1,4 @@ -//: innerclasses/GreenhouseController.java +// innerclasses/GreenhouseController.java // ©2015 MindView LLC: see Copyright.txt // Configure and execute the greenhouse system. // {Args: 5000} @@ -25,7 +25,8 @@ public class GreenhouseController { new Integer(args[0]))); gc.run(); } -} /* Output: +} +/* Output: Bing! Thermostat on night setting Light is on @@ -35,4 +36,4 @@ Greenhouse water is off Thermostat on day setting Restarting system Terminating -*///:~ +*/ diff --git a/innerclasses/GreenhouseControls.java b/innerclasses/GreenhouseControls.java index bb93ff9b..bc29c40e 100644 --- a/innerclasses/GreenhouseControls.java +++ b/innerclasses/GreenhouseControls.java @@ -1,4 +1,4 @@ -//: innerclasses/GreenhouseControls.java +// innerclasses/GreenhouseControls.java // ©2015 MindView LLC: see Copyright.txt // This produces a specific application of the // control system, all in a single class. Inner @@ -124,4 +124,4 @@ public class GreenhouseControls extends Controller { @Override public String toString() { return "Terminating"; } } -} ///:~ +} diff --git a/innerclasses/InheritInner.java b/innerclasses/InheritInner.java index f6562fce..c93f7d41 100644 --- a/innerclasses/InheritInner.java +++ b/innerclasses/InheritInner.java @@ -1,4 +1,4 @@ -//: innerclasses/InheritInner.java +// innerclasses/InheritInner.java // ©2015 MindView LLC: see Copyright.txt // Inheriting an inner class. @@ -15,4 +15,5 @@ public class InheritInner extends WithInner.Inner { WithInner wi = new WithInner(); InheritInner ii = new InheritInner(wi); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/LambdaExpressions.java b/innerclasses/LambdaExpressions.java index 15ec75db..2412c79f 100644 --- a/innerclasses/LambdaExpressions.java +++ b/innerclasses/LambdaExpressions.java @@ -1,4 +1,4 @@ -//: innerclasses/LambdaExpressions.java +// innerclasses/LambdaExpressions.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -39,10 +39,11 @@ public class LambdaExpressions { print(le.bod2.detailed("Oh!")); print(le.mult.twoArg("Pi! ", 3.14159)); } -} /* Output: +} +/* Output: Short info Short info Hi! More details Oh! No Parens! Pi! 3.14159 -*///:~ +*/ diff --git a/innerclasses/LocalInnerClass.java b/innerclasses/LocalInnerClass.java index e1debd8b..e2a7d571 100644 --- a/innerclasses/LocalInnerClass.java +++ b/innerclasses/LocalInnerClass.java @@ -1,4 +1,4 @@ -//: innerclasses/LocalInnerClass.java +// innerclasses/LocalInnerClass.java // ©2015 MindView LLC: see Copyright.txt // Holds a sequence of Objects. import static com.mindviewinc.util.Print.*; @@ -49,7 +49,8 @@ public class LocalInnerClass { for(int i = 0; i < 5; i++) print(c2.next()); } -} /* Output: +} +/* Output: LocalCounter() Counter() Local inner 0 @@ -62,4 +63,4 @@ Anonymous inner 6 Anonymous inner 7 Anonymous inner 8 Anonymous inner 9 -*///:~ +*/ diff --git a/innerclasses/MethodReferences.java b/innerclasses/MethodReferences.java index 002a678f..f588642a 100644 --- a/innerclasses/MethodReferences.java +++ b/innerclasses/MethodReferences.java @@ -1,4 +1,4 @@ -//: innerclasses/MethodReferences.java +// innerclasses/MethodReferences.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -20,7 +20,8 @@ public class MethodReferences { descriptions.add(new Description(k)); descriptions.forEach(Description::show); // (2) } -} /* Output: +} +/* Output: Every Good Boy @@ -31,4 +32,4 @@ Good Boy Deserves Fudge -*///:~ +*/ diff --git a/innerclasses/MultiImplementation.java b/innerclasses/MultiImplementation.java index 38d9e513..9a8b43d1 100644 --- a/innerclasses/MultiImplementation.java +++ b/innerclasses/MultiImplementation.java @@ -1,4 +1,4 @@ -//: innerclasses/MultiImplementation.java +// innerclasses/MultiImplementation.java // ©2015 MindView LLC: see Copyright.txt // With concrete or abstract classes, inner // classes are the only way to produce the effect @@ -20,4 +20,5 @@ public class MultiImplementation { takesD(z); takesE(z.makeE()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/MultiNestingAccess.java b/innerclasses/MultiNestingAccess.java index 52bc0b51..3abcf686 100644 --- a/innerclasses/MultiNestingAccess.java +++ b/innerclasses/MultiNestingAccess.java @@ -1,4 +1,4 @@ -//: innerclasses/MultiNestingAccess.java +// innerclasses/MultiNestingAccess.java // ©2015 MindView LLC: see Copyright.txt // Nested classes can access all members of all // levels of the classes they are nested within. @@ -23,4 +23,5 @@ public class MultiNestingAccess { MNA.A.B mnaab = mnaa.new B(); mnaab.h(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel1.java b/innerclasses/Parcel1.java index 4b68f81a..973093c9 100644 --- a/innerclasses/Parcel1.java +++ b/innerclasses/Parcel1.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel1.java +// innerclasses/Parcel1.java // ©2015 MindView LLC: see Copyright.txt // Creating inner classes. @@ -25,6 +25,7 @@ public class Parcel1 { Parcel1 p = new Parcel1(); p.ship("Tasmania"); } -} /* Output: +} +/* Output: Tasmania -*///:~ +*/ diff --git a/innerclasses/Parcel10.java b/innerclasses/Parcel10.java index 85edda48..0fbe1b7b 100644 --- a/innerclasses/Parcel10.java +++ b/innerclasses/Parcel10.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel10.java +// innerclasses/Parcel10.java // ©2015 MindView LLC: see Copyright.txt // Using "instance initialization" to perform // construction on an anonymous inner class. @@ -23,6 +23,7 @@ public class Parcel10 { Parcel10 p = new Parcel10(); Destination d = p.destination("Tasmania", 101.395F); } -} /* Output: +} +/* Output: Over budget! -*///:~ +*/ diff --git a/innerclasses/Parcel11.java b/innerclasses/Parcel11.java index 2b282650..3b00b9eb 100644 --- a/innerclasses/Parcel11.java +++ b/innerclasses/Parcel11.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel11.java +// innerclasses/Parcel11.java // ©2015 MindView LLC: see Copyright.txt // Nested classes (static inner classes). @@ -34,4 +34,5 @@ public class Parcel11 { Contents c = contents(); Destination d = destination("Tasmania"); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel2.java b/innerclasses/Parcel2.java index beb7e1ad..8fc5a882 100644 --- a/innerclasses/Parcel2.java +++ b/innerclasses/Parcel2.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel2.java +// innerclasses/Parcel2.java // ©2015 MindView LLC: see Copyright.txt // Returning a reference to an inner class. @@ -33,6 +33,7 @@ public class Parcel2 { Parcel2.Contents c = q.contents(); Parcel2.Destination d = q.to("Borneo"); } -} /* Output: +} +/* Output: Tasmania -*///:~ +*/ diff --git a/innerclasses/Parcel3.java b/innerclasses/Parcel3.java index d9fe151d..c6dede3b 100644 --- a/innerclasses/Parcel3.java +++ b/innerclasses/Parcel3.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel3.java +// innerclasses/Parcel3.java // ©2015 MindView LLC: see Copyright.txt // Using .new to create instances of inner classes. @@ -19,4 +19,5 @@ public class Parcel3 { Parcel3.Contents c = p.new Contents(); Parcel3.Destination d = p.new Destination("Tasmania"); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel5.java b/innerclasses/Parcel5.java index d23aab96..b9862db4 100644 --- a/innerclasses/Parcel5.java +++ b/innerclasses/Parcel5.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel5.java +// innerclasses/Parcel5.java // ©2015 MindView LLC: see Copyright.txt // Nesting a class within a method. @@ -18,4 +18,5 @@ public class Parcel5 { Parcel5 p = new Parcel5(); Destination d = p.destination("Tasmania"); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel6.java b/innerclasses/Parcel6.java index 3097ac89..c445ccf1 100644 --- a/innerclasses/Parcel6.java +++ b/innerclasses/Parcel6.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel6.java +// innerclasses/Parcel6.java // ©2015 MindView LLC: see Copyright.txt // Nesting a class within a scope. @@ -23,4 +23,5 @@ public class Parcel6 { Parcel6 p = new Parcel6(); p.track(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel7.java b/innerclasses/Parcel7.java index 022b8bdd..19693402 100644 --- a/innerclasses/Parcel7.java +++ b/innerclasses/Parcel7.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel7.java +// innerclasses/Parcel7.java // ©2015 MindView LLC: see Copyright.txt // Returning an instance of an anonymous inner class. @@ -14,4 +14,5 @@ public class Parcel7 { Parcel7 p = new Parcel7(); Contents c = p.contents(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel7b.java b/innerclasses/Parcel7b.java index 0dff33f8..e32a1f19 100644 --- a/innerclasses/Parcel7b.java +++ b/innerclasses/Parcel7b.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel7b.java +// innerclasses/Parcel7b.java // ©2015 MindView LLC: see Copyright.txt // Expanded version of Parcel7.java @@ -13,4 +13,5 @@ public class Parcel7b { Parcel7b p = new Parcel7b(); Contents c = p.contents(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel8.java b/innerclasses/Parcel8.java index 30b6c5da..b378fb7b 100644 --- a/innerclasses/Parcel8.java +++ b/innerclasses/Parcel8.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel8.java +// innerclasses/Parcel8.java // ©2015 MindView LLC: see Copyright.txt // Calling the base-class constructor. @@ -16,4 +16,5 @@ public class Parcel8 { Parcel8 p = new Parcel8(); Wrapping w = p.wrapping(10); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/Parcel9.java b/innerclasses/Parcel9.java index 32198b64..59cd1cd6 100644 --- a/innerclasses/Parcel9.java +++ b/innerclasses/Parcel9.java @@ -1,4 +1,4 @@ -//: innerclasses/Parcel9.java +// innerclasses/Parcel9.java // ©2015 MindView LLC: see Copyright.txt // An anonymous inner class that performs // initialization. A briefer version of Parcel5.java. @@ -17,4 +17,5 @@ public class Parcel9 { Parcel9 p = new Parcel9(); Destination d = p.destination("Tasmania"); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/RunnableMethodReference.java b/innerclasses/RunnableMethodReference.java index ea099324..3f5e7d7e 100644 --- a/innerclasses/RunnableMethodReference.java +++ b/innerclasses/RunnableMethodReference.java @@ -1,4 +1,4 @@ -//: innerclasses/RunnableMethodReference.java +// innerclasses/RunnableMethodReference.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates method references import static com.mindviewinc.util.Print.*; @@ -29,9 +29,10 @@ public class RunnableMethodReference { rmr.robject = rmr::f; rmr.robject.run(); } -} /* Output: +} +/* Output: f() g() External.go() f() -*///:~ +*/ diff --git a/innerclasses/Sequence.java b/innerclasses/Sequence.java index faff03da..e514d85d 100644 --- a/innerclasses/Sequence.java +++ b/innerclasses/Sequence.java @@ -1,4 +1,4 @@ -//: innerclasses/Sequence.java +// innerclasses/Sequence.java // ©2015 MindView LLC: see Copyright.txt // Holds a sequence of Objects. @@ -38,6 +38,7 @@ public class Sequence { selector.next(); } } -} /* Output: +} +/* Output: 0 1 2 3 4 5 6 7 8 9 -*///:~ +*/ diff --git a/innerclasses/TestBed.java b/innerclasses/TestBed.java index 08372e64..07c0716b 100644 --- a/innerclasses/TestBed.java +++ b/innerclasses/TestBed.java @@ -1,4 +1,4 @@ -//: innerclasses/TestBed.java +// innerclasses/TestBed.java // ©2015 MindView LLC: see Copyright.txt // Putting test code in a nested class. // {main: TestBed$Tester} @@ -11,6 +11,7 @@ public class TestBed { t.f(); } } -} /* Output: +} +/* Output: f() -*///:~ +*/ diff --git a/innerclasses/TestParcel.java b/innerclasses/TestParcel.java index 5af2ebad..1a4eac91 100644 --- a/innerclasses/TestParcel.java +++ b/innerclasses/TestParcel.java @@ -1,4 +1,4 @@ -//: innerclasses/TestParcel.java +// innerclasses/TestParcel.java // ©2015 MindView LLC: see Copyright.txt class Parcel4 { @@ -31,4 +31,5 @@ public class TestParcel { // Illegal -- can't access private class: //! Parcel4.PContents pc = p.new PContents(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/innerclasses/UnboundMethodReference.java b/innerclasses/UnboundMethodReference.java index 71640020..bd089ff0 100644 --- a/innerclasses/UnboundMethodReference.java +++ b/innerclasses/UnboundMethodReference.java @@ -1,4 +1,4 @@ -//: innerclasses/UnboundMethodReference.java +// innerclasses/UnboundMethodReference.java // ©2015 MindView LLC: see Copyright.txt // Method reference without an object. import java.util.*; @@ -21,10 +21,11 @@ public class UnboundMethodReference { Function xfr = X::f; print(xfr.apply(new X())); } -} /* Output: +} +/* Output: 22 Rain Spain Plain X.f() -*///:~ +*/ diff --git a/innerclasses/Wrapping.java b/innerclasses/Wrapping.java index 4cdcc666..ff9e0e76 100644 --- a/innerclasses/Wrapping.java +++ b/innerclasses/Wrapping.java @@ -1,7 +1,7 @@ -//: innerclasses/Wrapping.java +// innerclasses/Wrapping.java // ©2015 MindView LLC: see Copyright.txt public class Wrapping { private int i; public Wrapping(int x) { i = x; } public int value() { return i; } -} ///:~ +} diff --git a/innerclasses/arr/ArgReturnReferences.java b/innerclasses/arr/ArgReturnReferences.java index f242d635..93989efa 100644 --- a/innerclasses/arr/ArgReturnReferences.java +++ b/innerclasses/arr/ArgReturnReferences.java @@ -1,4 +1,4 @@ -//: innerclasses/arr/ArgReturnReferences.java +// innerclasses/arr/ArgReturnReferences.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates method references package innerclasses.arr; @@ -28,7 +28,8 @@ public class ArgReturnReferences { print(arr.f1arg.apply(y)); print(arr.f2arg.apply(y, "Howdy")); } -} /* Output: +} +/* Output: Y Y Howdy -*///:~ +*/ diff --git a/innerclasses/controller/Controller.java b/innerclasses/controller/Controller.java index a207326e..9569f94a 100644 --- a/innerclasses/controller/Controller.java +++ b/innerclasses/controller/Controller.java @@ -1,4 +1,4 @@ -//: innerclasses/controller/Controller.java +// innerclasses/controller/Controller.java // ©2015 MindView LLC: see Copyright.txt // The reusable framework for control systems. package innerclasses.controller; @@ -19,4 +19,4 @@ public class Controller { eventList.remove(e); } } -} ///:~ +} diff --git a/innerclasses/controller/Event.java b/innerclasses/controller/Event.java index 1d60ae46..d7a4c882 100644 --- a/innerclasses/controller/Event.java +++ b/innerclasses/controller/Event.java @@ -1,4 +1,4 @@ -//: innerclasses/controller/Event.java +// innerclasses/controller/Event.java // ©2015 MindView LLC: see Copyright.txt // The common methods for any control event. package innerclasses.controller; @@ -17,4 +17,4 @@ public abstract class Event { return System.nanoTime() >= eventTime; } public abstract void action(); -} ///:~ +} diff --git a/innerclasses/mui/MultiInterfaces.java b/innerclasses/mui/MultiInterfaces.java index d3edb66f..8ec68c6b 100644 --- a/innerclasses/mui/MultiInterfaces.java +++ b/innerclasses/mui/MultiInterfaces.java @@ -1,4 +1,4 @@ -//: innerclasses/mui/MultiInterfaces.java +// innerclasses/mui/MultiInterfaces.java // ©2015 MindView LLC: see Copyright.txt // Two ways that a class can implement multiple interfaces. package innerclasses.mui; @@ -26,4 +26,5 @@ public class MultiInterfaces { takesB(x); takesB(y.makeB()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/interfaces/AdaptedRandomDoubles.java b/interfaces/AdaptedRandomDoubles.java index 2bae7e77..1a3ac3cb 100644 --- a/interfaces/AdaptedRandomDoubles.java +++ b/interfaces/AdaptedRandomDoubles.java @@ -1,4 +1,4 @@ -//: interfaces/AdaptedRandomDoubles.java +// interfaces/AdaptedRandomDoubles.java // ©2015 MindView LLC: see Copyright.txt // Creating an adapter with inheritance. import java.nio.*; @@ -23,8 +23,9 @@ implements Readable { while(s.hasNextDouble()) System.out.print(s.nextDouble() + " "); } -} /* Output: +} +/* Output: 0.7271157860730044 0.5309454508634242 0.16020656493302599 0.18847866977771732 0.5166020801268457 0.2678662084200585 0.2613610344283964 -*///:~ +*/ diff --git a/interfaces/Adventure.java b/interfaces/Adventure.java index 1d7a3467..46f18ab1 100644 --- a/interfaces/Adventure.java +++ b/interfaces/Adventure.java @@ -1,4 +1,4 @@ -//: interfaces/Adventure.java +// interfaces/Adventure.java // ©2015 MindView LLC: see Copyright.txt // Multiple interfaces. @@ -36,4 +36,5 @@ public class Adventure { v(h); // Treat it as a CanFly w(h); // Treat it as an ActionCharacter } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/interfaces/Factories.java b/interfaces/Factories.java index 72df7f6b..c7e9672f 100644 --- a/interfaces/Factories.java +++ b/interfaces/Factories.java @@ -1,4 +1,4 @@ -//: interfaces/Factories.java +// interfaces/Factories.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -48,9 +48,10 @@ public class Factories { // Implementations are completely interchangeable: serviceConsumer(new Implementation2Factory()); } -} /* Output: +} +/* Output: Implementation1 method1 Implementation1 method2 Implementation2 method1 Implementation2 method2 -*///:~ +*/ diff --git a/interfaces/Games.java b/interfaces/Games.java index 7762089b..a3e819bb 100644 --- a/interfaces/Games.java +++ b/interfaces/Games.java @@ -1,4 +1,4 @@ -//: interfaces/Games.java +// interfaces/Games.java // ©2015 MindView LLC: see Copyright.txt // A Game framework using Factory Methods. import static com.mindviewinc.util.Print.*; @@ -46,7 +46,8 @@ public class Games { playGame(new CheckersFactory()); playGame(new ChessFactory()); } -} /* Output: +} +/* Output: Checkers move 0 Checkers move 1 Checkers move 2 @@ -54,4 +55,4 @@ Chess move 0 Chess move 1 Chess move 2 Chess move 3 -*///:~ +*/ diff --git a/interfaces/HorrorShow.java b/interfaces/HorrorShow.java index 8d4adbb8..4ebcf811 100644 --- a/interfaces/HorrorShow.java +++ b/interfaces/HorrorShow.java @@ -1,4 +1,4 @@ -//: interfaces/HorrorShow.java +// interfaces/HorrorShow.java // ©2015 MindView LLC: see Copyright.txt // Extending an interface with inheritance. @@ -52,4 +52,5 @@ public class HorrorShow { v(vlad); w(vlad); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/interfaces/InterfaceCollision.java b/interfaces/InterfaceCollision.java index e28473e2..ccfe78b2 100644 --- a/interfaces/InterfaceCollision.java +++ b/interfaces/InterfaceCollision.java @@ -1,4 +1,4 @@ -//: interfaces/InterfaceCollision.java +// interfaces/InterfaceCollision.java // ©2015 MindView LLC: see Copyright.txt package interfaces; @@ -27,4 +27,4 @@ class C4 extends C implements I3 { // Methods differ only by return type: //! class C5 extends C implements I1 {} -//! interface I4 extends I1, I3 {} ///:~ +//! interface I4 extends I1, I3 {} diff --git a/interfaces/Months.java b/interfaces/Months.java index c23760ae..d1fcac5a 100644 --- a/interfaces/Months.java +++ b/interfaces/Months.java @@ -1,4 +1,4 @@ -//: interfaces/Months.java +// interfaces/Months.java // ©2015 MindView LLC: see Copyright.txt // Using interfaces to create groups of constants. package interfaces; @@ -9,4 +9,4 @@ public interface Months { APRIL = 4, MAY = 5, JUNE = 6, JULY = 7, AUGUST = 8, SEPTEMBER = 9, OCTOBER = 10, NOVEMBER = 11, DECEMBER = 12; -} ///:~ +} diff --git a/interfaces/RandVals.java b/interfaces/RandVals.java index 82b40fe0..73c88a41 100644 --- a/interfaces/RandVals.java +++ b/interfaces/RandVals.java @@ -1,4 +1,4 @@ -//: interfaces/RandVals.java +// interfaces/RandVals.java // ©2015 MindView LLC: see Copyright.txt // Initializing interface fields with // non-constant initializers. @@ -10,4 +10,4 @@ public interface RandVals { long RANDOM_LONG = RAND.nextLong() * 10; float RANDOM_FLOAT = RAND.nextLong() * 10; double RANDOM_DOUBLE = RAND.nextDouble() * 10; -} ///:~ +} diff --git a/interfaces/RandomDoubles.java b/interfaces/RandomDoubles.java index 3398ace2..d66d6b76 100644 --- a/interfaces/RandomDoubles.java +++ b/interfaces/RandomDoubles.java @@ -1,4 +1,4 @@ -//: interfaces/RandomDoubles.java +// interfaces/RandomDoubles.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -10,8 +10,9 @@ public class RandomDoubles { for(int i = 0; i < 7; i ++) System.out.print(rd.next() + " "); } -} /* Output: +} +/* Output: 0.7271157860730044 0.5309454508634242 0.16020656493302599 0.18847866977771732 0.5166020801268457 0.2678662084200585 0.2613610344283964 -*///:~ +*/ diff --git a/interfaces/RandomWords.java b/interfaces/RandomWords.java index e2e13dcf..d824f032 100644 --- a/interfaces/RandomWords.java +++ b/interfaces/RandomWords.java @@ -1,4 +1,4 @@ -//: interfaces/RandomWords.java +// interfaces/RandomWords.java // ©2015 MindView LLC: see Copyright.txt // Implementing an interface to conform to a method. import java.nio.*; @@ -31,7 +31,8 @@ public class RandomWords implements Readable { while(s.hasNext()) System.out.println(s.next()); } -} /* Output: +} +/* Output: Yazeruyac Fowenucor Goeazimom @@ -42,4 +43,4 @@ Ruqicibui Numasetih Kuuuuozog Waqizeyoy -*///:~ +*/ diff --git a/interfaces/TestRandVals.java b/interfaces/TestRandVals.java index dbca9176..d130782c 100644 --- a/interfaces/TestRandVals.java +++ b/interfaces/TestRandVals.java @@ -1,4 +1,4 @@ -//: interfaces/TestRandVals.java +// interfaces/TestRandVals.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -9,9 +9,10 @@ public class TestRandVals { print(RandVals.RANDOM_FLOAT); print(RandVals.RANDOM_DOUBLE); } -} /* Output: +} +/* Output: 8 -32032247016559954 -8.5939291E18 5.779976127815049 -*///:~ +*/ diff --git a/interfaces/classprocessor/Apply.java b/interfaces/classprocessor/Apply.java index 7d32da39..2e6bf827 100644 --- a/interfaces/classprocessor/Apply.java +++ b/interfaces/classprocessor/Apply.java @@ -1,4 +1,4 @@ -//: interfaces/classprocessor/Apply.java +// interfaces/classprocessor/Apply.java // ©2015 MindView LLC: see Copyright.txt package interfaces.classprocessor; import java.util.*; @@ -45,7 +45,8 @@ public class Apply { process(new Downcase(), s); process(new Splitter(), s); } -} /* Output: +} +/* Output: Using Processor Upcase DISAGREEMENT WITH BELIEFS IS BY DEFINITION INCORRECT Using Processor Downcase @@ -53,4 +54,4 @@ disagreement with beliefs is by definition incorrect Using Processor Splitter [Disagreement, with, beliefs, is, by, definition, incorrect] -*///:~ +*/ diff --git a/interfaces/filters/BandPass.java b/interfaces/filters/BandPass.java index 6f9e9132..2f092d0b 100644 --- a/interfaces/filters/BandPass.java +++ b/interfaces/filters/BandPass.java @@ -1,4 +1,4 @@ -//: interfaces/filters/BandPass.java +// interfaces/filters/BandPass.java // ©2015 MindView LLC: see Copyright.txt package interfaces.filters; @@ -10,4 +10,4 @@ public class BandPass extends Filter { } @Override public Waveform process(Waveform input) { return input; } -} ///:~ +} diff --git a/interfaces/filters/Filter.java b/interfaces/filters/Filter.java index e637ada5..5ac91c83 100644 --- a/interfaces/filters/Filter.java +++ b/interfaces/filters/Filter.java @@ -1,4 +1,4 @@ -//: interfaces/filters/Filter.java +// interfaces/filters/Filter.java // ©2015 MindView LLC: see Copyright.txt package interfaces.filters; @@ -7,4 +7,4 @@ public class Filter { return getClass().getSimpleName(); } public Waveform process(Waveform input) { return input; } -} ///:~ +} diff --git a/interfaces/filters/HighPass.java b/interfaces/filters/HighPass.java index af433363..949c9ff7 100644 --- a/interfaces/filters/HighPass.java +++ b/interfaces/filters/HighPass.java @@ -1,4 +1,4 @@ -//: interfaces/filters/HighPass.java +// interfaces/filters/HighPass.java // ©2015 MindView LLC: see Copyright.txt package interfaces.filters; @@ -7,4 +7,4 @@ public class HighPass extends Filter { public HighPass(double cutoff) { this.cutoff = cutoff; } @Override public Waveform process(Waveform input) { return input; } -} ///:~ +} diff --git a/interfaces/filters/LowPass.java b/interfaces/filters/LowPass.java index fafdfcd0..71f210ed 100644 --- a/interfaces/filters/LowPass.java +++ b/interfaces/filters/LowPass.java @@ -1,4 +1,4 @@ -//: interfaces/filters/LowPass.java +// interfaces/filters/LowPass.java // ©2015 MindView LLC: see Copyright.txt package interfaces.filters; @@ -9,4 +9,4 @@ public class LowPass extends Filter { public Waveform process(Waveform input) { return input; // Dummy processing } -} ///:~ +} diff --git a/interfaces/filters/Waveform.java b/interfaces/filters/Waveform.java index 67c0cd6d..fe3bf27c 100644 --- a/interfaces/filters/Waveform.java +++ b/interfaces/filters/Waveform.java @@ -1,4 +1,4 @@ -//: interfaces/filters/Waveform.java +// interfaces/filters/Waveform.java // ©2015 MindView LLC: see Copyright.txt package interfaces.filters; @@ -7,4 +7,4 @@ public class Waveform { private final long id = counter++; @Override public String toString() { return "Waveform " + id; } -} ///:~ +} diff --git a/interfaces/interfaceprocessor/Apply.java b/interfaces/interfaceprocessor/Apply.java index 41dbdefc..fb0c870a 100644 --- a/interfaces/interfaceprocessor/Apply.java +++ b/interfaces/interfaceprocessor/Apply.java @@ -1,4 +1,4 @@ -//: interfaces/interfaceprocessor/Apply.java +// interfaces/interfaceprocessor/Apply.java // ©2015 MindView LLC: see Copyright.txt package interfaces.interfaceprocessor; import static com.mindviewinc.util.Print.*; @@ -8,4 +8,4 @@ public class Apply { print("Using Processor " + p.name()); print(p.process(s)); } -} ///:~ +} diff --git a/interfaces/interfaceprocessor/FilterProcessor.java b/interfaces/interfaceprocessor/FilterProcessor.java index 419388d5..d11d8f2f 100644 --- a/interfaces/interfaceprocessor/FilterProcessor.java +++ b/interfaces/interfaceprocessor/FilterProcessor.java @@ -1,4 +1,4 @@ -//: interfaces/interfaceprocessor/FilterProcessor.java +// interfaces/interfaceprocessor/FilterProcessor.java // ©2015 MindView LLC: see Copyright.txt package interfaces.interfaceprocessor; import interfaces.filters.*; @@ -24,11 +24,12 @@ public class FilterProcessor { Apply.process( new FilterAdapter(new BandPass(3.0, 4.0)), w); } -} /* Output: +} +/* Output: Using Processor LowPass Waveform 0 Using Processor HighPass Waveform 0 Using Processor BandPass Waveform 0 -*///:~ +*/ diff --git a/interfaces/interfaceprocessor/Processor.java b/interfaces/interfaceprocessor/Processor.java index cf33a5b5..5118be92 100644 --- a/interfaces/interfaceprocessor/Processor.java +++ b/interfaces/interfaceprocessor/Processor.java @@ -1,8 +1,8 @@ -//: interfaces/interfaceprocessor/Processor.java +// interfaces/interfaceprocessor/Processor.java // ©2015 MindView LLC: see Copyright.txt package interfaces.interfaceprocessor; public interface Processor { String name(); Object process(Object input); -} ///:~ +} diff --git a/interfaces/interfaceprocessor/StringProcessor.java b/interfaces/interfaceprocessor/StringProcessor.java index 4ac04a14..8a39edcb 100644 --- a/interfaces/interfaceprocessor/StringProcessor.java +++ b/interfaces/interfaceprocessor/StringProcessor.java @@ -1,4 +1,4 @@ -//: interfaces/interfaceprocessor/StringProcessor.java +// interfaces/interfaceprocessor/StringProcessor.java // ©2015 MindView LLC: see Copyright.txt package interfaces.interfaceprocessor; import java.util.*; @@ -38,7 +38,8 @@ class Splitter extends StringProcessor { public String process(Object input) { return Arrays.toString(((String)input).split(" ")); } -} /* Output: +} +/* Output: Using Processor Upcase IF SHE WEIGHS THE SAME AS A DUCK, SHE'S MADE OF WOOD Using Processor Downcase @@ -46,4 +47,4 @@ if she weighs the same as a duck, she's made of wood Using Processor Splitter [If, she, weighs, the, same, as, a, duck,, she's, made, of, wood] -*///:~ +*/ diff --git a/interfaces/music4/Music4.java b/interfaces/music4/Music4.java index 058c120a..58dcaf9b 100644 --- a/interfaces/music4/Music4.java +++ b/interfaces/music4/Music4.java @@ -1,4 +1,4 @@ -//: interfaces/music4/Music4.java +// interfaces/music4/Music4.java // ©2015 MindView LLC: see Copyright.txt // Abstract classes and methods. package interfaces.music4; @@ -85,10 +85,11 @@ public class Music4 { }; tuneAll(orchestra); } -} /* Output: +} +/* Output: Wind.play() MIDDLE_C Percussion.play() MIDDLE_C Stringed.play() MIDDLE_C Brass.play() MIDDLE_C Woodwind.play() MIDDLE_C -*///:~ +*/ diff --git a/interfaces/music5/Music5.java b/interfaces/music5/Music5.java index 9cd01bc3..01e2144e 100644 --- a/interfaces/music5/Music5.java +++ b/interfaces/music5/Music5.java @@ -1,4 +1,4 @@ -//: interfaces/music5/Music5.java +// interfaces/music5/Music5.java // ©2015 MindView LLC: see Copyright.txt // Interfaces. package interfaces.music5; @@ -78,10 +78,11 @@ public class Music5 { }; tuneAll(orchestra); } -} /* Output: +} +/* Output: Wind.play() MIDDLE_C Percussion.play() MIDDLE_C Stringed.play() MIDDLE_C Brass.play() MIDDLE_C Woodwind.play() MIDDLE_C -*///:~ +*/ diff --git a/interfaces/nesting/NestingInterfaces.java b/interfaces/nesting/NestingInterfaces.java index e76fc651..82c222c6 100644 --- a/interfaces/nesting/NestingInterfaces.java +++ b/interfaces/nesting/NestingInterfaces.java @@ -1,4 +1,4 @@ -//: interfaces/nesting/NestingInterfaces.java +// interfaces/nesting/NestingInterfaces.java // ©2015 MindView LLC: see Copyright.txt package interfaces.nesting; @@ -99,4 +99,5 @@ public class NestingInterfaces { A a2 = new A(); a2.receiveD(a.getD()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/io/AStoreCADState.java b/io/AStoreCADState.java index 3de143d1..328f53f6 100644 --- a/io/AStoreCADState.java +++ b/io/AStoreCADState.java @@ -1,4 +1,4 @@ -//: io/AStoreCADState.java +// io/AStoreCADState.java // ©2015 MindView LLC: see Copyright.txt // Saving the state of a pretend CAD system. import java.io.*; @@ -92,7 +92,8 @@ public class AStoreCADState { // Display the shapes: System.out.println(shapes); } -} /* Output: +} +/* Output: [class Circlecolor[3] xPos[58] yPos[55] dim[93] , class Squarecolor[3] xPos[61] yPos[61] dim[29] , class Linecolor[3] xPos[68] yPos[0] dim[22] @@ -104,4 +105,4 @@ public class AStoreCADState { , class Linecolor[3] xPos[4] yPos[83] dim[6] , class Circlecolor[3] xPos[75] yPos[10] dim[42] ] -*///:~ +*/ diff --git a/io/Alien.java b/io/Alien.java index 81e3dec1..94ffa45f 100644 --- a/io/Alien.java +++ b/io/Alien.java @@ -1,5 +1,5 @@ -//: io/Alien.java +// io/Alien.java // ©2015 MindView LLC: see Copyright.txt // A serializable class. import java.io.*; -public class Alien implements Serializable {} ///:~ +public class Alien implements Serializable {} diff --git a/io/AvailableCharSets.java b/io/AvailableCharSets.java index 7078db06..d4acda9a 100644 --- a/io/AvailableCharSets.java +++ b/io/AvailableCharSets.java @@ -1,4 +1,4 @@ -//: io/AvailableCharSets.java +// io/AvailableCharSets.java // ©2015 MindView LLC: see Copyright.txt // Displays Charsets and aliases import java.nio.charset.*; @@ -23,7 +23,8 @@ public class AvailableCharSets { print(); } } -} /* Output: (First 7 Lines) +} +/* Output: (First 7 Lines) Big5: csBig5 Big5-HKSCS: big5-hkscs, big5hk, Big5_HKSCS, big5hkscs CESU-8: CESU8, csCESU-8 @@ -36,4 +37,4 @@ GB18030: gb18030-2000 GB2312: gb2312, euc-cn, x-EUC-CN, euccn, EUC_CN, gb2312-80, gb2312-1980 ... -*///:~ +*/ diff --git a/io/BasicFileOutput.java b/io/BasicFileOutput.java index 3e639b51..63f05f59 100644 --- a/io/BasicFileOutput.java +++ b/io/BasicFileOutput.java @@ -1,4 +1,4 @@ -//: io/BasicFileOutput.java +// io/BasicFileOutput.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -19,4 +19,5 @@ public class BasicFileOutput { // Show the stored file: System.out.println(BufferedInputFile.read(file)); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/Blip3.java b/io/Blip3.java index 08334b55..dc49c166 100644 --- a/io/Blip3.java +++ b/io/Blip3.java @@ -1,4 +1,4 @@ -//: io/Blip3.java +// io/Blip3.java // ©2015 MindView LLC: see Copyright.txt // Reconstructing an externalizable object. import java.io.*; @@ -52,7 +52,8 @@ public class Blip3 implements Externalizable { b3 = (Blip3)in.readObject(); print(b3); } -} /* Output: +} +/* Output: Constructing objects: Blip3(String x, int a) A String 47 @@ -62,4 +63,4 @@ Recovering b3: Blip3 Constructor Blip3.readExternal A String 47 -*///:~ +*/ diff --git a/io/Blips.java b/io/Blips.java index 38e612ec..283dc3fa 100644 --- a/io/Blips.java +++ b/io/Blips.java @@ -1,4 +1,4 @@ -//: io/Blips.java +// io/Blips.java // ©2015 MindView LLC: see Copyright.txt // Simple use of Externalizable & a pitfall. import java.io.*; @@ -57,7 +57,8 @@ public class Blips { //! print("Recovering b2:"); //! b2 = (Blip2)in.readObject(); } -} /* Output: +} +/* Output: Constructing objects: Blip1 Constructor Blip2 Constructor @@ -67,4 +68,4 @@ Blip2.writeExternal Recovering b1: Blip1 Constructor Blip1.readExternal -*///:~ +*/ diff --git a/io/BufferToText.java b/io/BufferToText.java index 4027d79a..b10bb988 100644 --- a/io/BufferToText.java +++ b/io/BufferToText.java @@ -1,4 +1,4 @@ -//: io/BufferToText.java +// io/BufferToText.java // ©2015 MindView LLC: see Copyright.txt // Converting text to and from ByteBuffers import java.nio.*; @@ -48,9 +48,10 @@ public class BufferToText { buff.flip(); System.out.println(buff.asCharBuffer()); } -} /* Output: +} +/* Output: ???? Decoded using Cp1252: Some text Some text Some textNULNULNUL -*///:~ +*/ diff --git a/io/BufferedInputFile.java b/io/BufferedInputFile.java index b1038bd0..2a581fc9 100644 --- a/io/BufferedInputFile.java +++ b/io/BufferedInputFile.java @@ -1,4 +1,4 @@ -//: io/BufferedInputFile.java +// io/BufferedInputFile.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -21,4 +21,5 @@ public class BufferedInputFile { throws IOException { System.out.print(read("BufferedInputFile.java")); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/ChangeSystemOut.java b/io/ChangeSystemOut.java index b61adee2..1d2eeef9 100644 --- a/io/ChangeSystemOut.java +++ b/io/ChangeSystemOut.java @@ -1,4 +1,4 @@ -//: io/ChangeSystemOut.java +// io/ChangeSystemOut.java // ©2015 MindView LLC: see Copyright.txt // Turn System.out into a PrintWriter. import java.io.*; @@ -8,6 +8,7 @@ public class ChangeSystemOut { PrintWriter out = new PrintWriter(System.out, true); out.println("Hello, world"); } -} /* Output: +} +/* Output: Hello, world -*///:~ +*/ diff --git a/io/ChannelCopy.java b/io/ChannelCopy.java index f48aa5f5..b330f170 100644 --- a/io/ChannelCopy.java +++ b/io/ChannelCopy.java @@ -1,4 +1,4 @@ -//: io/ChannelCopy.java +// io/ChannelCopy.java // ©2015 MindView LLC: see Copyright.txt // Copying a file using channels and buffers // {Args: ChannelCopy.java test.txt} @@ -23,4 +23,5 @@ public class ChannelCopy { buffer.clear(); // Prepare for reading } } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/io/DirList.java b/io/DirList.java index 4554ce30..3d645461 100644 --- a/io/DirList.java +++ b/io/DirList.java @@ -1,4 +1,4 @@ -//: io/DirList.java +// io/DirList.java // ©2015 MindView LLC: see Copyright.txt // Display a directory listing using regular expressions. // {Args: "D.*\.java"} @@ -29,9 +29,10 @@ class DirFilter implements FilenameFilter { public boolean accept(File dir, String name) { return pattern.matcher(name).matches(); } -} /* Output: +} +/* Output: DirectoryDemo.java DirList.java DirList2.java DirList3.java -*///:~ +*/ diff --git a/io/DirList2.java b/io/DirList2.java index 1f9dd691..b66d0751 100644 --- a/io/DirList2.java +++ b/io/DirList2.java @@ -1,4 +1,4 @@ -//: io/DirList2.java +// io/DirList2.java // ©2015 MindView LLC: see Copyright.txt // Uses anonymous inner classes. // {Args: "D.*\.java"} @@ -28,9 +28,10 @@ public class DirList2 { for(String dirItem : list) System.out.println(dirItem); } -} /* Output: +} +/* Output: DirectoryDemo.java DirList.java DirList2.java DirList3.java -*///:~ +*/ diff --git a/io/DirList3.java b/io/DirList3.java index 7d550840..f95929cb 100644 --- a/io/DirList3.java +++ b/io/DirList3.java @@ -1,4 +1,4 @@ -//: io/DirList3.java +// io/DirList3.java // ©2015 MindView LLC: see Copyright.txt // Building the anonymous inner class "in-place." // {Args: "D.*\.java"} @@ -24,9 +24,10 @@ public class DirList3 { for(String dirItem : list) System.out.println(dirItem); } -} /* Output: +} +/* Output: DirectoryDemo.java DirList.java DirList2.java DirList3.java -*///:~ +*/ diff --git a/io/DirectoryDemo.java b/io/DirectoryDemo.java index 78b2ea25..a5136700 100644 --- a/io/DirectoryDemo.java +++ b/io/DirectoryDemo.java @@ -1,4 +1,4 @@ -//: io/DirectoryDemo.java +// io/DirectoryDemo.java // ©2015 MindView LLC: see Copyright.txt // Sample use of Directory utilities. import java.io.*; @@ -21,7 +21,8 @@ public class DirectoryDemo { for(File file : Directory.walk(".",".*[Zz].*\\.class")) print(file); } -} /* Output: +} +/* Output: [.\xfiles] .\TestEOF.class .\TestEOF.java @@ -35,4 +36,4 @@ public class DirectoryDemo { .\FreezeAlien.class .\GZIPcompress.class .\ZipCompress.class -*///:~ +*/ diff --git a/io/Echo.java b/io/Echo.java index 09729680..d99b7da8 100644 --- a/io/Echo.java +++ b/io/Echo.java @@ -1,4 +1,4 @@ -//: io/Echo.java +// io/Echo.java // ©2015 MindView LLC: see Copyright.txt // How to read from standard input. // {TimeOutDuringTesting} @@ -14,4 +14,5 @@ public class Echo { System.out.println(s); // An empty line or Ctrl-Z terminates the program } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/io/Endians.java b/io/Endians.java index d273e80a..5d82d1b3 100644 --- a/io/Endians.java +++ b/io/Endians.java @@ -1,4 +1,4 @@ -//: io/Endians.java +// io/Endians.java // ©2015 MindView LLC: see Copyright.txt // Endian differences and data storage. import java.nio.*; @@ -19,8 +19,9 @@ public class Endians { bb.asCharBuffer().put("abcdef"); print(Arrays.toString(bb.array())); } -} /* Output: +} +/* Output: [0, 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102] [0, 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102] [97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0] -*///:~ +*/ diff --git a/io/FileLocking.java b/io/FileLocking.java index 4f4ee0ac..5a1a08bf 100644 --- a/io/FileLocking.java +++ b/io/FileLocking.java @@ -1,4 +1,4 @@ -//: io/FileLocking.java +// io/FileLocking.java // ©2015 MindView LLC: see Copyright.txt import java.nio.channels.*; import java.util.concurrent.*; @@ -17,7 +17,8 @@ public class FileLocking { } } } -} /* Output: +} +/* Output: Locked File Released Lock -*///:~ +*/ diff --git a/io/FileOutputShortcut.java b/io/FileOutputShortcut.java index d788169c..7c1cc151 100644 --- a/io/FileOutputShortcut.java +++ b/io/FileOutputShortcut.java @@ -1,4 +1,4 @@ -//: io/FileOutputShortcut.java +// io/FileOutputShortcut.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -19,4 +19,5 @@ public class FileOutputShortcut { // Show the stored file: System.out.println(BufferedInputFile.read(file)); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/FormattedMemoryInput.java b/io/FormattedMemoryInput.java index 07cd3237..2f3a4424 100644 --- a/io/FormattedMemoryInput.java +++ b/io/FormattedMemoryInput.java @@ -1,4 +1,4 @@ -//: io/FormattedMemoryInput.java +// io/FormattedMemoryInput.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -16,4 +16,5 @@ public class FormattedMemoryInput { System.out.println("End of stream"); } } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/FreezeAlien.java b/io/FreezeAlien.java index d61ab389..b2ee24e2 100644 --- a/io/FreezeAlien.java +++ b/io/FreezeAlien.java @@ -1,4 +1,4 @@ -//: io/FreezeAlien.java +// io/FreezeAlien.java // ©2015 MindView LLC: see Copyright.txt // Create a serialized output file. import java.io.*; @@ -10,4 +10,5 @@ public class FreezeAlien { Alien quellek = new Alien(); out.writeObject(quellek); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/io/GZIPcompress.java b/io/GZIPcompress.java index 170fcf4a..83e99ab7 100644 --- a/io/GZIPcompress.java +++ b/io/GZIPcompress.java @@ -1,4 +1,4 @@ -//: io/GZIPcompress.java +// io/GZIPcompress.java // ©2015 MindView LLC: see Copyright.txt // {Args: GZIPcompress.java} import java.util.zip.*; @@ -34,4 +34,5 @@ public class GZIPcompress { while((s = in2.readLine()) != null) System.out.println(s); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/GetChannel.java b/io/GetChannel.java index 177ec17f..9000a3ee 100644 --- a/io/GetChannel.java +++ b/io/GetChannel.java @@ -1,4 +1,4 @@ -//: io/GetChannel.java +// io/GetChannel.java // ©2015 MindView LLC: see Copyright.txt // Getting channels from streams import java.nio.*; @@ -27,6 +27,7 @@ public class GetChannel { System.out.write(buff.get()); System.out.flush(); } -} /* Output: +} +/* Output: Some text Some more -*///:~ +*/ diff --git a/io/GetData.java b/io/GetData.java index cbe63a2a..6243bc89 100644 --- a/io/GetData.java +++ b/io/GetData.java @@ -1,4 +1,4 @@ -//: io/GetData.java +// io/GetData.java // ©2015 MindView LLC: see Copyright.txt // Getting different representations from a ByteBuffer import java.nio.*; @@ -43,7 +43,8 @@ public class GetData { print(bb.getDouble()); bb.rewind(); } -} /* Output: +} +/* Output: i = 1025 H o w d y ! 12390 @@ -51,4 +52,4 @@ H o w d y ! 99471142 9.9471144E7 9.9471142E7 -*///:~ +*/ diff --git a/io/IntBufferDemo.java b/io/IntBufferDemo.java index c8becd03..a370b378 100644 --- a/io/IntBufferDemo.java +++ b/io/IntBufferDemo.java @@ -1,4 +1,4 @@ -//: io/IntBufferDemo.java +// io/IntBufferDemo.java // ©2015 MindView LLC: see Copyright.txt // Manipulating ints in a ByteBuffer with an IntBuffer import java.nio.*; @@ -20,7 +20,8 @@ public class IntBufferDemo { System.out.println(i); } } -} /* Output: +} +/* Output: 99 11 42 @@ -29,4 +30,4 @@ public class IntBufferDemo { 143 811 1016 -*///:~ +*/ diff --git a/io/LargeMappedFiles.java b/io/LargeMappedFiles.java index 183acca3..3f4be792 100644 --- a/io/LargeMappedFiles.java +++ b/io/LargeMappedFiles.java @@ -1,4 +1,4 @@ -//: io/LargeMappedFiles.java +// io/LargeMappedFiles.java // ©2015 MindView LLC: see Copyright.txt // Creating a very large file using mapping. import java.nio.*; @@ -18,7 +18,8 @@ public class LargeMappedFiles { for(int i = length/2; i < length/2 + 6; i++) printnb((char)out.get(i)); } -} /* Output: +} +/* Output: Finished writing xxxxxx -*///:~ +*/ diff --git a/io/LockingMappedFiles.java b/io/LockingMappedFiles.java index 43228cd8..6ed17067 100644 --- a/io/LockingMappedFiles.java +++ b/io/LockingMappedFiles.java @@ -1,4 +1,4 @@ -//: io/LockingMappedFiles.java +// io/LockingMappedFiles.java // ©2015 MindView LLC: see Copyright.txt // Locking portions of a mapped file. import java.nio.*; @@ -45,9 +45,10 @@ public class LockingMappedFiles { } } } -} /* Output: +} +/* Output: Locked: 75497471 to 113246206 Locked: 0 to 50331647 Released: 75497471 to 113246206 Released: 0 to 50331647 -*///:~ +*/ diff --git a/io/Logon.java b/io/Logon.java index c8076c09..5bd7370c 100644 --- a/io/Logon.java +++ b/io/Logon.java @@ -1,4 +1,4 @@ -//: io/Logon.java +// io/Logon.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates the "transient" keyword. import java.util.concurrent.*; @@ -34,7 +34,8 @@ public class Logon implements Serializable { a = (Logon)in.readObject(); print("logon a = " + a); } -} /* Output: +} +/* Output: logon a = logon info: username: Hulk date: Mon Jun 15 15:47:51 PDT 2015 @@ -44,4 +45,4 @@ logon a = logon info: username: Hulk date: Mon Jun 15 15:47:51 PDT 2015 password: null -*///:~ +*/ diff --git a/io/MakeDirectories.java b/io/MakeDirectories.java index 3926235e..872fa312 100644 --- a/io/MakeDirectories.java +++ b/io/MakeDirectories.java @@ -1,4 +1,4 @@ -//: io/MakeDirectories.java +// io/MakeDirectories.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates using the File class to // create directories and manipulate files. @@ -68,16 +68,17 @@ public class MakeDirectories { fileData(f); } } -} /* Output: +} +/* Output: created MakeDirectoriesTest Absolute path: C:\Users\Bruce\Dropbox\___OnJava\ExtractedEx amples\io\MakeDirectoriesTest - Can read: true - Can write: true - getName: MakeDirectoriesTest - getParent: null - getPath: MakeDirectoriesTest - length: 0 - lastModified: 1434408471084 +Can read: true +Can write: true +getName: MakeDirectoriesTest +getParent: null +getPath: MakeDirectoriesTest +length: 0 +lastModified: 1434408471084 It's a directory -*///:~ +*/ diff --git a/io/MappedIO.java b/io/MappedIO.java index f37eff41..792663f8 100644 --- a/io/MappedIO.java +++ b/io/MappedIO.java @@ -1,4 +1,4 @@ -//: io/MappedIO.java +// io/MappedIO.java // ©2015 MindView LLC: see Copyright.txt import java.nio.*; import java.nio.channels.*; @@ -106,11 +106,12 @@ public class MappedIO { for(Tester test : tests) test.runTest(); } -} /* Output: +} +/* Output: Stream Write: 0.45 Mapped Write: 0.04 Stream Read: 0.42 Mapped Read: 0.03 Stream Read/Write: 3.43 Mapped Read/Write: 0.00 -*///:~ +*/ diff --git a/io/MemoryInput.java b/io/MemoryInput.java index d876e7d8..99590901 100644 --- a/io/MemoryInput.java +++ b/io/MemoryInput.java @@ -1,4 +1,4 @@ -//: io/MemoryInput.java +// io/MemoryInput.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -11,4 +11,5 @@ public class MemoryInput { while((c = in.read()) != -1) System.out.print((char)c); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/MyWorld.java b/io/MyWorld.java index 0f58b1c8..aeac34da 100644 --- a/io/MyWorld.java +++ b/io/MyWorld.java @@ -1,4 +1,4 @@ -//: io/MyWorld.java +// io/MyWorld.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; import java.util.*; @@ -52,7 +52,8 @@ public class MyWorld { print("animals2: " + animals2); print("animals3: " + animals3); } -} /* Output: +} +/* Output: animals: [Bosco the dog[Animal@19e0bfd], House@139a55 , Ralph the hamster[Animal@1db9742], House@139a55 , Molly the cat[Animal@106d69c], House@139a55 @@ -69,4 +70,4 @@ animals3: [Bosco the dog[Animal@a3a380], House@1453f44 , Ralph the hamster[Animal@ad8086], House@1453f44 , Molly the cat[Animal@be858], House@1453f44 ] -*///:~ +*/ diff --git a/io/OSExecuteDemo.java b/io/OSExecuteDemo.java index 884acc64..17927579 100644 --- a/io/OSExecuteDemo.java +++ b/io/OSExecuteDemo.java @@ -1,4 +1,4 @@ -//: io/OSExecuteDemo.java +// io/OSExecuteDemo.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates standard I/O redirection. import com.mindviewinc.util.*; @@ -7,10 +7,11 @@ public class OSExecuteDemo { public static void main(String[] args) { OSExecute.command("javap OSExecuteDemo"); } -} /* Output: +} +/* Output: Compiled from "OSExecuteDemo.java" public class OSExecuteDemo { public OSExecuteDemo(); public static void main(java.lang.String[]); } -*///:~ +*/ diff --git a/io/PreferencesDemo.java b/io/PreferencesDemo.java index 024bbafe..53c2cd72 100644 --- a/io/PreferencesDemo.java +++ b/io/PreferencesDemo.java @@ -1,4 +1,4 @@ -//: io/PreferencesDemo.java +// io/PreferencesDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.prefs.*; import static com.mindviewinc.util.Print.*; @@ -20,11 +20,12 @@ public class PreferencesDemo { print("How many companions does Dorothy have? " + prefs.getInt("Companions", 0)); } -} /* Output: +} +/* Output: Location: Oz Footwear: Ruby Slippers Companions: 4 Are there witches?: true UsageCount: 33 How many companions does Dorothy have? 4 -*///:~ +*/ diff --git a/io/RecoverCADState.java b/io/RecoverCADState.java index 3504c5ab..9491335a 100644 --- a/io/RecoverCADState.java +++ b/io/RecoverCADState.java @@ -1,4 +1,4 @@ -//: io/RecoverCADState.java +// io/RecoverCADState.java // ©2015 MindView LLC: see Copyright.txt // Restoring the state of the pretend CAD system. // {RunFirst: AStoreCADState} @@ -17,7 +17,8 @@ public class RecoverCADState { List shapes = (List)in.readObject(); System.out.println(shapes); } -} /* Output: +} +/* Output: [class Circlecolor[1] xPos[58] yPos[55] dim[93] , class Squarecolor[0] xPos[61] yPos[61] dim[29] , class Linecolor[3] xPos[68] yPos[0] dim[22] @@ -29,4 +30,4 @@ public class RecoverCADState { , class Linecolor[3] xPos[4] yPos[83] dim[6] , class Circlecolor[1] xPos[75] yPos[10] dim[42] ] -*///:~ +*/ diff --git a/io/Redirecting.java b/io/Redirecting.java index ebe733e3..453e3723 100644 --- a/io/Redirecting.java +++ b/io/Redirecting.java @@ -1,4 +1,4 @@ -//: io/Redirecting.java +// io/Redirecting.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates standard I/O redirection. import java.io.*; @@ -24,4 +24,5 @@ public class Redirecting { } System.setOut(console); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/io/SerialCtl.java b/io/SerialCtl.java index ca597609..95111ed4 100644 --- a/io/SerialCtl.java +++ b/io/SerialCtl.java @@ -1,4 +1,4 @@ -//: io/SerialCtl.java +// io/SerialCtl.java // ©2015 MindView LLC: see Copyright.txt // Controlling serialization by adding your own // writeObject() and readObject() methods. @@ -36,11 +36,12 @@ public class SerialCtl implements Serializable { SerialCtl sc2 = (SerialCtl)in.readObject(); System.out.println("After:\n" + sc2); } -} /* Output: +} +/* Output: Before: Not Transient: Test1 Transient: Test2 After: Not Transient: Test1 Transient: Test2 -*///:~ +*/ diff --git a/io/StoringAndRecoveringData.java b/io/StoringAndRecoveringData.java index bfec39c7..611485d0 100644 --- a/io/StoringAndRecoveringData.java +++ b/io/StoringAndRecoveringData.java @@ -1,4 +1,4 @@ -//: io/StoringAndRecoveringData.java +// io/StoringAndRecoveringData.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -23,9 +23,10 @@ public class StoringAndRecoveringData { System.out.println(in.readDouble()); System.out.println(in.readUTF()); } -} /* Output: +} +/* Output: 3.14159 That was pi 1.41413 Square root of 2 -*///:~ +*/ diff --git a/io/TestEOF.java b/io/TestEOF.java index 90c2b2d5..fdecf919 100644 --- a/io/TestEOF.java +++ b/io/TestEOF.java @@ -1,4 +1,4 @@ -//: io/TestEOF.java +// io/TestEOF.java // ©2015 MindView LLC: see Copyright.txt // Testing for end of file while reading a byte at a time. import java.io.*; @@ -12,4 +12,5 @@ public class TestEOF { while(in.available() != 0) System.out.write(in.readByte()); } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/TransferTo.java b/io/TransferTo.java index 881d4533..31092571 100644 --- a/io/TransferTo.java +++ b/io/TransferTo.java @@ -1,4 +1,4 @@ -//: io/TransferTo.java +// io/TransferTo.java // ©2015 MindView LLC: see Copyright.txt // Using transferTo() between channels // {Args: TransferTo.java TransferTo.txt} @@ -18,4 +18,5 @@ public class TransferTo { // Or: // out.transferFrom(in, 0, in.size()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/io/UsingBuffers.java b/io/UsingBuffers.java index 9af94d16..5780da36 100644 --- a/io/UsingBuffers.java +++ b/io/UsingBuffers.java @@ -1,4 +1,4 @@ -//: io/UsingBuffers.java +// io/UsingBuffers.java // ©2015 MindView LLC: see Copyright.txt import java.nio.*; import static com.mindviewinc.util.Print.*; @@ -24,8 +24,9 @@ public class UsingBuffers { symmetricScramble(cb); print(cb.rewind()); } -} /* Output: +} +/* Output: UsingBuffers sUniBgfuefsr UsingBuffers -*///:~ +*/ diff --git a/io/UsingRandomAccessFile.java b/io/UsingRandomAccessFile.java index ebeb3bce..7acdba8c 100644 --- a/io/UsingRandomAccessFile.java +++ b/io/UsingRandomAccessFile.java @@ -1,4 +1,4 @@ -//: io/UsingRandomAccessFile.java +// io/UsingRandomAccessFile.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -27,7 +27,8 @@ public class UsingRandomAccessFile { rf.close(); display(); } -} /* Output: +} +/* Output: Value 0: 0.0 Value 1: 1.414 Value 2: 2.828 @@ -44,4 +45,4 @@ Value 4: 5.656 Value 5: 47.0001 Value 6: 8.484 The end of the file -*///:~ +*/ diff --git a/io/ViewBuffers.java b/io/ViewBuffers.java index c3897cdb..8cf459ee 100644 --- a/io/ViewBuffers.java +++ b/io/ViewBuffers.java @@ -1,4 +1,4 @@ -//: io/ViewBuffers.java +// io/ViewBuffers.java // ©2015 MindView LLC: see Copyright.txt import java.nio.*; import static com.mindviewinc.util.Print.*; @@ -48,7 +48,8 @@ public class ViewBuffers { while(db.hasRemaining()) printnb(db.position()+ " -> " + db.get() + ", "); } -} /* Output: +} +/* Output: Byte Buffer 0 -> 0, 1 -> 0, 2 -> 0, 3 -> 0, 4 -> 0, 5 -> 0, 6 -> 0, 7 -> 97, Char Buffer 0 -> NUL, 1 -> NUL, 2 -> NUL, 3 -> a, @@ -57,4 +58,4 @@ Int Buffer 0 -> 0, 1 -> 97, Long Buffer 0 -> 97, Short Buffer 0 -> 0, 1 -> 0, 2 -> 0, 3 -> 97, Double Buffer 0 -> 4.8E-322, -*///:~ +*/ diff --git a/io/Worm.java b/io/Worm.java index dda847d0..89b8ccd9 100644 --- a/io/Worm.java +++ b/io/Worm.java @@ -1,4 +1,4 @@ -//: io/Worm.java +// io/Worm.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates object serialization. import java.io.*; @@ -70,7 +70,8 @@ public class Worm implements Serializable { Worm w3 = (Worm)in2.readObject(); print(s + "w3 = " + w3); } -} /* Output: +} +/* Output: Worm constructor: 6 Worm constructor: 5 Worm constructor: 4 @@ -82,4 +83,4 @@ Worm storage w2 = :a(853):b(119):c(802):d(788):e(199):f(881) Worm storage w3 = :a(853):b(119):c(802):d(788):e(199):f(881) -*///:~ +*/ diff --git a/io/ZipCompress.java b/io/ZipCompress.java index a3019db5..0fa6ea5b 100644 --- a/io/ZipCompress.java +++ b/io/ZipCompress.java @@ -1,4 +1,4 @@ -//: io/ZipCompress.java +// io/ZipCompress.java // ©2015 MindView LLC: see Copyright.txt // Uses Zip compression to compress any // number of files given on the command line. @@ -61,4 +61,5 @@ public class ZipCompress { } /* if(args.length == 1) */ } -} /* Output: (Execute to see) *///:~ +} +/* Output: (Execute to see) */ diff --git a/io/xfiles/ThawAlien.java b/io/xfiles/ThawAlien.java index 217e8825..f59f22c8 100644 --- a/io/xfiles/ThawAlien.java +++ b/io/xfiles/ThawAlien.java @@ -1,4 +1,4 @@ -//: io/xfiles/ThawAlien.java +// io/xfiles/ThawAlien.java // ©2015 MindView LLC: see Copyright.txt // Recover a serialized file package io.xfiles; @@ -11,6 +11,7 @@ public class ThawAlien { Object mystery = in.readObject(); System.out.println(mystery.getClass()); } -} /* Output: +} +/* Output: class Alien -*///:~ +*/ diff --git a/logging/ConfigureLogging.java b/logging/ConfigureLogging.java index a016bb6d..85e6d2d1 100644 --- a/logging/ConfigureLogging.java +++ b/logging/ConfigureLogging.java @@ -1,4 +1,4 @@ -//: logging/ConfigureLogging.java +// logging/ConfigureLogging.java // ©2015 MindView LLC: see Copyright.txt // {JVMArgs: -Djava.util.logging.config.file=log.prop} import java.util.logging.*; @@ -39,12 +39,13 @@ public class ConfigureLogging { logger.warning("Warning"); logger.severe("Severe"); } -} /* Output: +} +/* Output: Logger Name : net Level: SEVERE - Logger Name : com.mindviewinc Level: FINEST - Logger Name : com.mindviewinc.util Level: INFO - Logger Name : com.mindviewinc.test Level: FINER - Logger Name : random Level: SEVERE +Logger Name : com.mindviewinc Level: FINEST +Logger Name : com.mindviewinc.util Level: INFO +Logger Name : com.mindviewinc.test Level: FINER +Logger Name : random Level: SEVERE ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages SEVERE: Severe @@ -82,4 +83,4 @@ Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages SEVERE: Severe Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages SEVERE: Severe -*///:~ +*/ diff --git a/logging/CustomHandler.java b/logging/CustomHandler.java index 1c6bc9ce..82325d60 100644 --- a/logging/CustomHandler.java +++ b/logging/CustomHandler.java @@ -1,4 +1,4 @@ -//: logging/CustomHandler.java +// logging/CustomHandler.java // ©2015 MindView LLC: see Copyright.txt // How to write custom handler import java.util.logging.*; @@ -31,7 +31,8 @@ public class CustomHandler { logger.info("Logging Info"); System.out.print(trace); } -} /* Output: +} +/* Output: [WARNING:, CustomHandler:, main:, , , INFO:, CustomHandler:, main:, , ] @@ -40,4 +41,4 @@ Jun 15, 2015 3:47:52 PM CustomHandler main WARNING: Logging Warning Jun 15, 2015 3:47:52 PM CustomHandler main INFO: Logging Info -*///:~ +*/ diff --git a/logging/InfoLogging.java b/logging/InfoLogging.java index 6a31cc26..92c79e21 100644 --- a/logging/InfoLogging.java +++ b/logging/InfoLogging.java @@ -1,4 +1,4 @@ -//: logging/InfoLogging.java +// logging/InfoLogging.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.*; @@ -8,8 +8,9 @@ public class InfoLogging { public static void main(String[] args) { logger.info("Logging: INFO-level message"); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM InfoLogging main INFO: Logging: INFO-level message -*///:~ +*/ diff --git a/logging/InfoLogging2.java b/logging/InfoLogging2.java index a68fde52..4b229025 100644 --- a/logging/InfoLogging2.java +++ b/logging/InfoLogging2.java @@ -1,4 +1,4 @@ -//: logging/InfoLogging2.java +// logging/InfoLogging2.java // ©2015 MindView LLC: see Copyright.txt // Guaranteeing proper class and method names import java.util.logging.*; @@ -10,8 +10,9 @@ public class InfoLogging2 { logger.logp(Level.INFO, "InfoLogging2", "main", "Logging an INFO-level message"); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM InfoLogging2 main INFO: Logging an INFO-level message -*///:~ +*/ diff --git a/logging/LogToFile.java b/logging/LogToFile.java index dd351ab9..31258a15 100644 --- a/logging/LogToFile.java +++ b/logging/LogToFile.java @@ -1,4 +1,4 @@ -//: logging/LogToFile.java +// logging/LogToFile.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.*; @@ -11,8 +11,9 @@ public class LogToFile { new FileHandler("LogToFile.xml")); logger.info("A message logged to the file"); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM LogToFile main INFO: A message logged to the file -*///:~ +*/ diff --git a/logging/LogToFile2.java b/logging/LogToFile2.java index ece107d3..1fd272eb 100644 --- a/logging/LogToFile2.java +++ b/logging/LogToFile2.java @@ -1,4 +1,4 @@ -//: logging/LogToFile2.java +// logging/LogToFile2.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.*; @@ -13,8 +13,9 @@ public class LogToFile2 { logger.addHandler(logFile); logger.info("A message logged to the file"); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM LogToFile2 main INFO: A message logged to the file -*///:~ +*/ diff --git a/logging/LoggingLevelManipulation.java b/logging/LoggingLevelManipulation.java index f7f5245c..bc58bcc2 100644 --- a/logging/LoggingLevelManipulation.java +++ b/logging/LoggingLevelManipulation.java @@ -1,4 +1,4 @@ -//: logging/LoggingLevelManipulation.java +// logging/LoggingLevelManipulation.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.Level; import java.util.logging.Logger; @@ -57,19 +57,20 @@ public class LoggingLevelManipulation { System.out.println("net level: FINEST"); logMessages(); } -} /* Output: +} +/* Output: -- printing levels -- net : null com.mindviewinc : null com.mindviewinc.util : null com.mindviewinc.test : null random : null - -- printing levels -- net : SEVERE com.mindviewinc : null +-- printing levels -- net : SEVERE com.mindviewinc : null com.mindviewinc.util : null com.mindviewinc.test : null random : null net level: SEVERE - -- printing levels -- net : SEVERE com.mindviewinc : null +-- printing levels -- net : SEVERE com.mindviewinc : null com.mindviewinc.util : FINEST com.mindviewinc.test : FINEST random : FINEST individual loggers set to FINEST - -- printing levels -- net : FINEST com.mindviewinc : null +-- printing levels -- net : FINEST com.mindviewinc : null com.mindviewinc.util : FINEST com.mindviewinc.test : FINEST random : FINEST net level: FINEST @@ -197,4 +198,4 @@ WARNING: random Warning Jun 15, 2015 3:47:52 PM LoggingLevelManipulation printLogMessages SEVERE: random Severe -*///:~ +*/ diff --git a/logging/LoggingLevels.java b/logging/LoggingLevels.java index 1910d39a..a33d711e 100644 --- a/logging/LoggingLevels.java +++ b/logging/LoggingLevels.java @@ -1,4 +1,4 @@ -//: logging/LoggingLevels.java +// logging/LoggingLevels.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.Level; import java.util.logging.Logger; @@ -31,7 +31,8 @@ public class LoggingLevels { System.out.println("com level: SEVERE"); logMessages(); } -} /* Output: +} +/* Output: com level: SEVERE individual loggers set to FINEST com level: SEVERE @@ -52,4 +53,4 @@ Jun 15, 2015 3:47:52 PM LoggingLevels logMessages SEVERE: test : severe Jun 15, 2015 3:47:52 PM LoggingLevels logMessages INFO: random : info -*///:~ +*/ diff --git a/logging/MultipleHandlers.java b/logging/MultipleHandlers.java index 5cbd979f..dc998503 100644 --- a/logging/MultipleHandlers.java +++ b/logging/MultipleHandlers.java @@ -1,4 +1,4 @@ -//: logging/MultipleHandlers.java +// logging/MultipleHandlers.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.*; @@ -14,10 +14,11 @@ public class MultipleHandlers { logger.warning( "Output to multiple handlers"); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM MultipleHandlers main WARNING: Output to multiple handlers Jun 15, 2015 3:47:52 PM MultipleHandlers main WARNING: Output to multiple handlers -*///:~ +*/ diff --git a/logging/MultipleHandlers2.java b/logging/MultipleHandlers2.java index 135201a2..765d37c3 100644 --- a/logging/MultipleHandlers2.java +++ b/logging/MultipleHandlers2.java @@ -1,4 +1,4 @@ -//: logging/MultipleHandlers2.java +// logging/MultipleHandlers2.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.*; @@ -15,8 +15,9 @@ public class MultipleHandlers2 { logger.warning( "Output to multiple handlers"); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM MultipleHandlers2 main WARNING: Output to multiple handlers -*///:~ +*/ diff --git a/logging/PrintableLogRecord.java b/logging/PrintableLogRecord.java index 3f0d9069..7b58509f 100644 --- a/logging/PrintableLogRecord.java +++ b/logging/PrintableLogRecord.java @@ -1,4 +1,4 @@ -//: logging/PrintableLogRecord.java +// logging/PrintableLogRecord.java // ©2015 MindView LLC: see Copyright.txt // Override LogRecord toString() import java.util.logging.*; @@ -43,7 +43,8 @@ PrintableLogRecord extends LogRecord { Level.FINEST, "Simple Log Record"); System.out.println(logRecord); } -} /* Output: +} +/* Output: Level LoggerName Message @@ -56,4 +57,4 @@ SourceClassName SourceMethodName Thread Id<1> Thrown -*///:~ +*/ diff --git a/logging/SimpleFilter.java b/logging/SimpleFilter.java index b65a1eef..6abb3124 100644 --- a/logging/SimpleFilter.java +++ b/logging/SimpleFilter.java @@ -1,4 +1,4 @@ -//: logging/SimpleFilter.java +// logging/SimpleFilter.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.*; @@ -28,7 +28,8 @@ public class SimpleFilter { logger.info("After setting filter.."); sendLogMessages(); } -} /* Output: +} +/* Output: ___[ Error Output ]___ Jun 15, 2015 3:47:52 PM SimpleFilter sendLogMessages WARNING: A duck in the house! @@ -38,4 +39,4 @@ Jun 15, 2015 3:47:52 PM SimpleFilter main INFO: After setting filter.. Jun 15, 2015 3:47:52 PM SimpleFilter sendLogMessages WARNING: A duck in the house! -*///:~ +*/ diff --git a/logging/SimpleFormatterExample.java b/logging/SimpleFormatterExample.java index b662c872..64b6bfc6 100644 --- a/logging/SimpleFormatterExample.java +++ b/logging/SimpleFormatterExample.java @@ -1,4 +1,4 @@ -//: logging/SimpleFormatterExample.java +// logging/SimpleFormatterExample.java // ©2015 MindView LLC: see Copyright.txt import java.util.logging.*; @@ -25,10 +25,11 @@ public class SimpleFormatterExample { logger.addHandler(conHdlr); logMessages(); } -} /* Output: +} +/* Output: ___[ Error Output ]___ INFO : SimpleFormatterExample -:- logMessages -:- Line One INFO : SimpleFormatterExample -:- logMessages -:- Line Two -*///:~ +*/ diff --git a/logging/log.prop b/logging/log.prop index fbc77a36..2d4cebec 100644 --- a/logging/log.prop +++ b/logging/log.prop @@ -1,12 +1,12 @@ -//: logging/log.prop +// logging/log.prop #### Configuration File #### # Global Params # Handlers installed for the root logger handlers= java.util.logging.ConsoleHandler java.util.logging.FileHandler -# Level for root loggeris used by any logger +# Level for root logger—is used by any logger # that does not have its level set .level= FINEST -# Initialization classthe public default constructor +# Initialization class—the public default constructor # of this class is called by the Logging framework config = ConfigureLogging @@ -30,4 +30,3 @@ com.mindviewinc.level = FINEST com.mindviewinc.util.level = INFO com.mindviewinc.test.level = FINER random.level= SEVERE -///:~ diff --git a/network/ChatterClient.java b/network/ChatterClient.java index 0ffcb158..51026fb3 100644 --- a/network/ChatterClient.java +++ b/network/ChatterClient.java @@ -1,4 +1,4 @@ -//: network/ChatterClient.java +// network/ChatterClient.java // ©2015 MindView LLC: see Copyright.txt // {ValidateByHand} // Tests the ChatterServer by starting multiple @@ -61,4 +61,4 @@ public class ChatterClient extends Thread { for(int i = 0; i <= 10; i++) new ChatterClient(i).start(); } -} ///:~ +} diff --git a/network/ChatterServer.java b/network/ChatterServer.java index f287d80b..abe8d337 100644 --- a/network/ChatterServer.java +++ b/network/ChatterServer.java @@ -1,4 +1,4 @@ -//: network/ChatterServer.java +// network/ChatterServer.java // ©2015 MindView LLC: see Copyright.txt // {ValidateByHand} // A server that echoes datagrams @@ -47,4 +47,4 @@ public class ChatterServer { new TimedAbort(5); // Terminate after 5 seconds new ChatterServer(); } -} ///:~ +} diff --git a/network/Dgram.java b/network/Dgram.java index d7697f93..342ab1c9 100644 --- a/network/Dgram.java +++ b/network/Dgram.java @@ -1,4 +1,4 @@ -//: network/Dgram.java +// network/Dgram.java // ©2015 MindView LLC: see Copyright.txt // A utility class to convert back and forth // Between Strings and DataGramPackets. @@ -15,4 +15,4 @@ public class Dgram { return new String(p.getData(), 0, p.getLength()); } -} ///:~ +} diff --git a/network/LocalHost.java b/network/LocalHost.java index dd9db2d5..9ef57928 100644 --- a/network/LocalHost.java +++ b/network/LocalHost.java @@ -1,4 +1,4 @@ -//: network/LocalHost.java +// network/LocalHost.java // ©2015 MindView LLC: see Copyright.txt // The local loopback IP address import java.net.*; @@ -16,9 +16,10 @@ public class LocalHost { System.out.println(local3); System.out.println(local4); } -} /* Output: +} +/* Output: localhost/127.0.0.1 localhost/127.0.0.1 /127.0.0.1 localhost/127.0.0.1 -*///:~ +*/ diff --git a/network/MultiSimpleClient.java b/network/MultiSimpleClient.java index 3137dcae..b6fb4822 100644 --- a/network/MultiSimpleClient.java +++ b/network/MultiSimpleClient.java @@ -1,4 +1,4 @@ -//: network/MultiSimpleClient.java +// network/MultiSimpleClient.java // ©2015 MindView LLC: see Copyright.txt // Client that tests the MultiSimpleServer // by starting up multiple clients. @@ -84,4 +84,4 @@ public class MultiSimpleClient { Thread.sleep(100); } } -} ///:~ +} diff --git a/network/MultiSimpleServer.java b/network/MultiSimpleServer.java index 5675c913..e7187efe 100644 --- a/network/MultiSimpleServer.java +++ b/network/MultiSimpleServer.java @@ -1,4 +1,4 @@ -//: network/MultiSimpleServer.java +// network/MultiSimpleServer.java // ©2015 MindView LLC: see Copyright.txt // A server that uses multithreading // to handle any number of clients. @@ -72,4 +72,4 @@ public class MultiSimpleServer { s.close(); } } -} ///:~ +} diff --git a/network/SimpleClient.java b/network/SimpleClient.java index 9f64cbd3..ad6d0641 100644 --- a/network/SimpleClient.java +++ b/network/SimpleClient.java @@ -1,4 +1,4 @@ -//: network/SimpleClient.java +// network/SimpleClient.java // ©2015 MindView LLC: see Copyright.txt // Very simple client that just sends // lines to the server and reads lines @@ -44,4 +44,4 @@ public class SimpleClient { socket.close(); } } -} ///:~ +} diff --git a/network/SimpleServer.java b/network/SimpleServer.java index 3104cef6..6e092b1f 100644 --- a/network/SimpleServer.java +++ b/network/SimpleServer.java @@ -1,4 +1,4 @@ -//: network/SimpleServer.java +// network/SimpleServer.java // ©2015 MindView LLC: see Copyright.txt // Very simple server that just // echoes whatever the client sends. @@ -45,4 +45,4 @@ public class SimpleServer { s.close(); } } -} ///:~ +} diff --git a/network/WhoAmI.java b/network/WhoAmI.java index 09da6ccd..d12e2d75 100644 --- a/network/WhoAmI.java +++ b/network/WhoAmI.java @@ -1,4 +1,4 @@ -//: network/WhoAmI.java +// network/WhoAmI.java // ©2015 MindView LLC: see Copyright.txt // Finds out your machine name and network address // when you're connected to the Internet. @@ -11,7 +11,8 @@ public class WhoAmI { System.out.println(whoami.getHostName()); System.out.println(whoami.getHostAddress()); } -} /* Output: +} +/* Output: groot 192.168.70.115 -*///:~ +*/ diff --git a/objects/Documentation1.java b/objects/Documentation1.java index 3f41d67d..504c177f 100644 --- a/objects/Documentation1.java +++ b/objects/Documentation1.java @@ -1,4 +1,4 @@ -//: objects/Documentation1.java +// objects/Documentation1.java // ©2015 MindView LLC: see Copyright.txt /** A class comment */ public class Documentation1 { @@ -6,4 +6,4 @@ public class Documentation1 { public int i; /** A method comment */ public void f() {} -} ///:~ +} diff --git a/objects/Documentation2.java b/objects/Documentation2.java index 2550d488..8ea09616 100644 --- a/objects/Documentation2.java +++ b/objects/Documentation2.java @@ -1,9 +1,7 @@ -//: objects/Documentation2.java +// objects/Documentation2.java // ©2015 MindView LLC: see Copyright.txt -/** -*
-* System.out.println(new Date());
-* 
-*/ +/**
+ * System.out.println(new Date());
+ * 
+ */ public class Documentation2 {} -///:~ diff --git a/objects/Documentation3.java b/objects/Documentation3.java index 48db4948..13aa4ab8 100644 --- a/objects/Documentation3.java +++ b/objects/Documentation3.java @@ -1,12 +1,10 @@ -//: objects/Documentation3.java +// objects/Documentation3.java // ©2015 MindView LLC: see Copyright.txt -/** -* You can even insert a list: -*
    -*
  1. Item one -*
  2. Item two -*
  3. Item three -*
-*/ +/** You can even insert a list: + *
    + *
  1. Item one + *
  2. Item two + *
  3. Item three + *
+ */ public class Documentation3 {} -///:~ diff --git a/objects/HelloDate.java b/objects/HelloDate.java index 7d2c288c..3a76501c 100644 --- a/objects/HelloDate.java +++ b/objects/HelloDate.java @@ -1,4 +1,4 @@ -//: objects/HelloDate.java +// objects/HelloDate.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -6,18 +6,19 @@ import java.util.*; * Displays a string and today's date. * @author Bruce Eckel * @author www.MindviewInc.com - * @version 4.0 -*/ + * @version 5.0 + */ public class HelloDate { /** Entry point to class & application. * @param args array of string arguments * @throws exceptions No exceptions thrown - */ + */ public static void main(String[] args) { System.out.println("Hello, it's: "); System.out.println(new Date()); } -} /* Output: +} +/* Output: Hello, it's: Mon Jun 15 15:47:53 PDT 2015 -*///:~ +*/ diff --git a/objects/ShowProperties.java b/objects/ShowProperties.java index bab922de..9cb9a3ef 100644 --- a/objects/ShowProperties.java +++ b/objects/ShowProperties.java @@ -1,4 +1,4 @@ -//: objects/ShowProperties.java +// objects/ShowProperties.java // ©2015 MindView LLC: see Copyright.txt public class ShowProperties { @@ -8,7 +8,8 @@ public class ShowProperties { System.out.println( System.getProperty("java.library.path")); } -} /* Output: (First 20 Lines) +} +/* Output: (First 20 Lines) -- listing properties -- java.runtime.name=Java(TM) SE Runtime Environment sun.boot.library.path=C:\Program Files @@ -32,4 +33,4 @@ java.endorsed.dirs=C:\Program Files (x86)\Java\jre1.8.0_... os.arch=x86 java.io.tmpdir=C:\Users\Bruce\AppData\Local\Temp\ ... -*///:~ +*/ diff --git a/operators/AllOps.java b/operators/AllOps.java index 3e90b74e..eb6dfc53 100644 --- a/operators/AllOps.java +++ b/operators/AllOps.java @@ -1,4 +1,4 @@ -//: operators/AllOps.java +// operators/AllOps.java // ©2015 MindView LLC: see Copyright.txt // Tests all the operators on all the primitive data types // to show which ones are accepted by the Java compiler. @@ -406,4 +406,4 @@ public class AllOps { long l = (long)x; float f = (float)x; } -} ///:~ +} diff --git a/operators/Assignment.java b/operators/Assignment.java index ae798b1b..f2ffa286 100644 --- a/operators/Assignment.java +++ b/operators/Assignment.java @@ -1,4 +1,4 @@ -//: operators/Assignment.java +// operators/Assignment.java // ©2015 MindView LLC: see Copyright.txt // Assignment with objects is a bit tricky. import static com.mindviewinc.util.Print.*; @@ -22,8 +22,9 @@ public class Assignment { print("3: t1.level: " + t1.level + ", t2.level: " + t2.level); } -} /* Output: +} +/* Output: 1: t1.level: 9, t2.level: 47 2: t1.level: 47, t2.level: 47 3: t1.level: 27, t2.level: 27 -*///:~ +*/ diff --git a/operators/AutoInc.java b/operators/AutoInc.java index 73ceb41c..beefcc52 100644 --- a/operators/AutoInc.java +++ b/operators/AutoInc.java @@ -1,4 +1,4 @@ -//: operators/AutoInc.java +// operators/AutoInc.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates the ++ and -- operators. import static com.mindviewinc.util.Print.*; @@ -14,7 +14,8 @@ public class AutoInc { print("i-- : " + i--); // Post-decrement print("i : " + i); } -} /* Output: +} +/* Output: i : 1 ++i : 2 i++ : 2 @@ -22,4 +23,4 @@ i : 3 --i : 2 i-- : 2 i : 1 -*///:~ +*/ diff --git a/operators/BitManipulation.java b/operators/BitManipulation.java index 50f680f6..59f5378f 100644 --- a/operators/BitManipulation.java +++ b/operators/BitManipulation.java @@ -1,4 +1,4 @@ -//: operators/BitManipulation.java +// operators/BitManipulation.java // ©2015 MindView LLC: see Copyright.txt // Using the bitwise operators. import java.util.*; @@ -57,7 +57,8 @@ public class BitManipulation { print(s + ", long: " + l + ", binary:\n " + Long.toBinaryString(l)); } -} /* Output: (First 32 Lines) +} +/* Output: (First 32 Lines) -1, int: -1, binary: 11111111111111111111111111111111 +1, int: 1, binary: @@ -91,4 +92,4 @@ i >>> 5, int: 97591828, binary: (~i) >>> 5, int: 36625899, binary: 10001011101101110111101011 ... -*///:~ +*/ diff --git a/operators/Bool.java b/operators/Bool.java index 948890d0..aba57136 100644 --- a/operators/Bool.java +++ b/operators/Bool.java @@ -1,4 +1,4 @@ -//: operators/Bool.java +// operators/Bool.java // ©2015 MindView LLC: see Copyright.txt // Relational and logical operators. import java.util.*; @@ -26,7 +26,8 @@ public class Bool { print("(i < 10) || (j < 10) is " + ((i < 10) || (j < 10)) ); } -} /* Output: +} +/* Output: i = 58 j = 55 i > j is true @@ -37,4 +38,4 @@ i == j is false i != j is true (i < 10) && (j < 10) is false (i < 10) || (j < 10) is false -*///:~ +*/ diff --git a/operators/Casting.java b/operators/Casting.java index 26624d7f..5284a583 100644 --- a/operators/Casting.java +++ b/operators/Casting.java @@ -1,14 +1,15 @@ -//: operators/Casting.java +// operators/Casting.java // ©2015 MindView LLC: see Copyright.txt public class Casting { public static void main(String[] args) { int i = 200; long lng = (long)i; - lng = i; // "Widening," so cast not really required + lng = i; // "Widening," so a cast is not required long lng2 = (long)200; lng2 = 200; // A "narrowing conversion": i = (int)lng2; // Cast required } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/operators/CastingNumbers.java b/operators/CastingNumbers.java index d389f123..8d48c165 100644 --- a/operators/CastingNumbers.java +++ b/operators/CastingNumbers.java @@ -1,4 +1,4 @@ -//: operators/CastingNumbers.java +// operators/CastingNumbers.java // ©2015 MindView LLC: see Copyright.txt // What happens when you cast a float // or double to an integral value? @@ -13,9 +13,10 @@ public class CastingNumbers { print("(int)fabove: " + (int)fabove); print("(int)fbelow: " + (int)fbelow); } -} /* Output: +} +/* Output: (int)above: 0 (int)below: 0 (int)fabove: 0 (int)fbelow: 0 -*///:~ +*/ diff --git a/operators/EqualsMethod.java b/operators/EqualsMethod.java index 2e83879f..00c0321b 100644 --- a/operators/EqualsMethod.java +++ b/operators/EqualsMethod.java @@ -1,4 +1,4 @@ -//: operators/EqualsMethod.java +// operators/EqualsMethod.java // ©2015 MindView LLC: see Copyright.txt public class EqualsMethod { @@ -7,6 +7,7 @@ public class EqualsMethod { Integer n2 = 47; System.out.println(n1.equals(n2)); } -} /* Output: +} +/* Output: true -*///:~ +*/ diff --git a/operators/EqualsMethod2.java b/operators/EqualsMethod2.java index 62eaf47a..8bfd695c 100644 --- a/operators/EqualsMethod2.java +++ b/operators/EqualsMethod2.java @@ -1,4 +1,4 @@ -//: operators/EqualsMethod2.java +// operators/EqualsMethod2.java // ©2015 MindView LLC: see Copyright.txt // Default equals() does not compare contents. @@ -13,6 +13,7 @@ public class EqualsMethod2 { v1.i = v2.i = 100; System.out.println(v1.equals(v2)); } -} /* Output: +} +/* Output: false -*///:~ +*/ diff --git a/operators/Equivalence.java b/operators/Equivalence.java index 8a20110a..5cdc9919 100644 --- a/operators/Equivalence.java +++ b/operators/Equivalence.java @@ -1,4 +1,4 @@ -//: operators/Equivalence.java +// operators/Equivalence.java // ©2015 MindView LLC: see Copyright.txt public class Equivalence { @@ -8,7 +8,8 @@ public class Equivalence { System.out.println(n1 == n2); System.out.println(n1 != n2); } -} /* Output: +} +/* Output: true false -*///:~ +*/ diff --git a/operators/Exponents.java b/operators/Exponents.java index 59d362ba..9e1953aa 100644 --- a/operators/Exponents.java +++ b/operators/Exponents.java @@ -1,4 +1,4 @@ -//: operators/Exponents.java +// operators/Exponents.java // ©2015 MindView LLC: see Copyright.txt // "e" means "10 to the power." @@ -12,7 +12,8 @@ public class Exponents { double expDouble2 = 47e47; // Automatically double System.out.println(expDouble); } -} /* Output: +} +/* Output: 1.39E-43 4.7E48 -*///:~ +*/ diff --git a/operators/HelloDate.java b/operators/HelloDate.java index 0143abdf..1619b4dd 100644 --- a/operators/HelloDate.java +++ b/operators/HelloDate.java @@ -1,4 +1,4 @@ -//: operators/HelloDate.java +// operators/HelloDate.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; import static com.mindviewinc.util.Print.*; @@ -8,7 +8,8 @@ public class HelloDate { print("Hello, it's: "); print(new Date()); } -} /* Output: +} +/* Output: Hello, it's: Mon Jun 15 15:47:53 PDT 2015 -*///:~ +*/ diff --git a/operators/Literals.java b/operators/Literals.java index 9cfde297..826ba5b1 100644 --- a/operators/Literals.java +++ b/operators/Literals.java @@ -1,4 +1,4 @@ -//: operators/Literals.java +// operators/Literals.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -35,7 +35,8 @@ public class Literals { double d2 = 1D; // double suffix // (Hex and Octal also work with long) } -} /* Output: +} +/* Output: i1: 101111 i2: 101111 i3: 1111111 @@ -46,4 +47,4 @@ blb: 110101 bls: 10111110101111 bli: 101111101011111010111110101111 bll: 101111101011111010111110101111 -*///:~ +*/ diff --git a/operators/MathOps.java b/operators/MathOps.java index 69b6a8e4..ab1bf221 100644 --- a/operators/MathOps.java +++ b/operators/MathOps.java @@ -1,4 +1,4 @@ -//: operators/MathOps.java +// operators/MathOps.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates the mathematical operators. import java.util.*; @@ -51,7 +51,8 @@ public class MathOps { u /= v; print("u /= v : " + u); } -} /* Output: +} +/* Output: j : 59 k : 56 j + k : 115 @@ -70,4 +71,4 @@ u += v : 10.471473 u -= v : 9.940527 u *= v : 5.2778773 u /= v : 9.940527 -*///:~ +*/ diff --git a/operators/Overflow.java b/operators/Overflow.java index 7aeeb6c4..e6a901d0 100644 --- a/operators/Overflow.java +++ b/operators/Overflow.java @@ -1,4 +1,4 @@ -//: operators/Overflow.java +// operators/Overflow.java // ©2015 MindView LLC: see Copyright.txt // Surprise! Java lets you overflow. @@ -9,7 +9,8 @@ public class Overflow { int bigger = big * 4; System.out.println("bigger = " + bigger); } -} /* Output: +} +/* Output: big = 2147483647 bigger = -4 -*///:~ +*/ diff --git a/operators/PassObject.java b/operators/PassObject.java index a194c818..0591cfa4 100644 --- a/operators/PassObject.java +++ b/operators/PassObject.java @@ -1,4 +1,4 @@ -//: operators/PassObject.java +// operators/PassObject.java // ©2015 MindView LLC: see Copyright.txt // Passing objects to methods might not be // what you're used to. @@ -19,7 +19,8 @@ public class PassObject { f(x); print("2: x.c: " + x.c); } -} /* Output: +} +/* Output: 1: x.c: a 2: x.c: z -*///:~ +*/ diff --git a/operators/Precedence.java b/operators/Precedence.java index 7fc3b7fa..bd8dff03 100644 --- a/operators/Precedence.java +++ b/operators/Precedence.java @@ -1,4 +1,4 @@ -//: operators/Precedence.java +// operators/Precedence.java // ©2015 MindView LLC: see Copyright.txt public class Precedence { @@ -8,6 +8,7 @@ public class Precedence { int b = x + (y - 2)/(2 + z); // (2) System.out.println("a = " + a + " b = " + b); } -} /* Output: +} +/* Output: a = 5 b = 1 -*///:~ +*/ diff --git a/operators/RoundingNumbers.java b/operators/RoundingNumbers.java index a8a63ed8..731f06d2 100644 --- a/operators/RoundingNumbers.java +++ b/operators/RoundingNumbers.java @@ -1,4 +1,4 @@ -//: operators/RoundingNumbers.java +// operators/RoundingNumbers.java // ©2015 MindView LLC: see Copyright.txt // Rounding floats and doubles. import static com.mindviewinc.util.Print.*; @@ -12,9 +12,10 @@ public class RoundingNumbers { print("Math.round(fabove): " + Math.round(fabove)); print("Math.round(fbelow): " + Math.round(fbelow)); } -} /* Output: +} +/* Output: Math.round(above): 1 Math.round(below): 0 Math.round(fabove): 1 Math.round(fbelow): 0 -*///:~ +*/ diff --git a/operators/ShortCircuit.java b/operators/ShortCircuit.java index 427d646e..9278646f 100644 --- a/operators/ShortCircuit.java +++ b/operators/ShortCircuit.java @@ -1,4 +1,4 @@ -//: operators/ShortCircuit.java +// operators/ShortCircuit.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates short-circuiting behavior // with logical operators. @@ -24,10 +24,11 @@ public class ShortCircuit { boolean b = test1(0) && test2(2) && test3(2); print("expression is " + b); } -} /* Output: +} +/* Output: test1(0) result: true test2(2) result: false expression is false -*///:~ +*/ diff --git a/operators/StringOperators.java b/operators/StringOperators.java index 9e1e201a..f2c605d3 100644 --- a/operators/StringOperators.java +++ b/operators/StringOperators.java @@ -1,4 +1,4 @@ -//: operators/StringOperators.java +// operators/StringOperators.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -12,9 +12,10 @@ public class StringOperators { print(s + (x + y + z)); print("" + x); // Shorthand for Integer.toString() } -} /* Output: +} +/* Output: x, y, z 012 0 x, y, z x, y, z (summed) = 3 0 -*///:~ +*/ diff --git a/operators/TernaryIfElse.java b/operators/TernaryIfElse.java index ce83c427..e15a12ee 100644 --- a/operators/TernaryIfElse.java +++ b/operators/TernaryIfElse.java @@ -1,4 +1,4 @@ -//: operators/TernaryIfElse.java +// operators/TernaryIfElse.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -18,9 +18,10 @@ public class TernaryIfElse { print(standardIfElse(9)); print(standardIfElse(10)); } -} /* Output: +} +/* Output: 900 100 900 100 -*///:~ +*/ diff --git a/operators/URShift.java b/operators/URShift.java index 6586f186..90c39932 100644 --- a/operators/URShift.java +++ b/operators/URShift.java @@ -1,4 +1,4 @@ -//: operators/URShift.java +// operators/URShift.java // ©2015 MindView LLC: see Copyright.txt // Test of unsigned right shift. import static com.mindviewinc.util.Print.*; @@ -25,7 +25,8 @@ public class URShift { print(Integer.toBinaryString(b)); print(Integer.toBinaryString(b>>>10)); } -} /* Output: +} +/* Output: 11111111111111111111111111111111 1111111111111111111111 11111111111111111111111111111111111111111111111111111111111 @@ -37,4 +38,4 @@ public class URShift { 11111111111111111111111111111111 11111111111111111111111111111111 1111111111111111111111 -*///:~ +*/ diff --git a/patterns/CommandPattern.java b/patterns/CommandPattern.java index b69af309..b70c1ff7 100644 --- a/patterns/CommandPattern.java +++ b/patterns/CommandPattern.java @@ -1,4 +1,4 @@ -//: patterns/CommandPattern.java +// patterns/CommandPattern.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -46,6 +46,7 @@ public class CommandPattern { macro.add(new IAm()); macro.execute(); } -} /* Output: +} +/* Output: Hello World! I'm the command pattern! -*///:~ +*/ diff --git a/patterns/CommandPattern2.java b/patterns/CommandPattern2.java index f8ee2815..491c2283 100644 --- a/patterns/CommandPattern2.java +++ b/patterns/CommandPattern2.java @@ -1,4 +1,4 @@ -//: patterns/CommandPattern2.java +// patterns/CommandPattern2.java // ©2015 MindView LLC: see Copyright.txt // Using the Runnable functional interface import java.util.*; @@ -45,6 +45,7 @@ public class CommandPattern2 { macro.add(new IAm2()); macro.execute.run(); } -} /* Output: +} +/* Output: Hello World! I'm the command pattern! -*///:~ +*/ diff --git a/patterns/CommandPattern3.java b/patterns/CommandPattern3.java index a350c2a3..4a4fce2c 100644 --- a/patterns/CommandPattern3.java +++ b/patterns/CommandPattern3.java @@ -1,4 +1,4 @@ -//: patterns/CommandPattern3.java +// patterns/CommandPattern3.java // ©2015 MindView LLC: see Copyright.txt // Just implement the Runnable interface! import java.util.*; @@ -32,6 +32,7 @@ public class CommandPattern3 { macro.commands.add(new IAm3()); macro.run(); } -} /* Output: +} +/* Output: Hello World! I'm the command pattern! -*///:~ +*/ diff --git a/patterns/Facade.java b/patterns/Facade.java index 84a8727b..93dfd926 100644 --- a/patterns/Facade.java +++ b/patterns/Facade.java @@ -1,4 +1,4 @@ -//: patterns/Facade.java +// patterns/Facade.java // ©2015 MindView LLC: see Copyright.txt class A { public A(int x) {} } @@ -19,4 +19,5 @@ public class Facade { B b = Facade.makeB(1); C c = Facade.makeC(1.0); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/patterns/PaperScissorsRock.java b/patterns/PaperScissorsRock.java index 1afe5f7a..46de9101 100644 --- a/patterns/PaperScissorsRock.java +++ b/patterns/PaperScissorsRock.java @@ -1,4 +1,4 @@ -//: patterns/PaperScissorsRock.java +// patterns/PaperScissorsRock.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of multiple dispatching. import java.util.*; @@ -106,7 +106,8 @@ public class PaperScissorsRock { Compete.match( items.get(i), items.get(i*2))); } -} /* Output: +} +/* Output: Paper <--> Paper : DRAW Paper <--> Rock : WIN Rock <--> Scissors : WIN @@ -127,4 +128,4 @@ Scissors <--> Rock : LOSE Rock <--> Paper : LOSE Scissors <--> Paper : WIN Paper <--> Rock : WIN -*///:~ +*/ diff --git a/patterns/ProxyDemo.java b/patterns/ProxyDemo.java index 4c050e63..655a5ec8 100644 --- a/patterns/ProxyDemo.java +++ b/patterns/ProxyDemo.java @@ -1,4 +1,4 @@ -//: patterns/ProxyDemo.java +// patterns/ProxyDemo.java // ©2015 MindView LLC: see Copyright.txt // Simple demonstration of the Proxy pattern. @@ -41,8 +41,9 @@ public class ProxyDemo { p.g(); p.h(); } -} /* Output: +} +/* Output: Implementation.f() Implementation.g() Implementation.h() -*///:~ +*/ diff --git a/patterns/ShapeFactory2.java b/patterns/ShapeFactory2.java index 0435c378..2e6346e7 100644 --- a/patterns/ShapeFactory2.java +++ b/patterns/ShapeFactory2.java @@ -1,4 +1,4 @@ -//: patterns/ShapeFactory2.java +// patterns/ShapeFactory2.java // ©2015 MindView LLC: see Copyright.txt // Polymorphic factory methods. import java.util.*; @@ -69,7 +69,8 @@ public class ShapeFactory2 { shapes.forEach(Shape::draw); shapes.forEach(Shape::erase); } -} /* Output: +} +/* Output: Circle.draw Square.draw Square.draw @@ -82,4 +83,4 @@ Square.erase Circle.erase Circle.erase Square.erase -*///:~ +*/ diff --git a/patterns/SingletonPattern.java b/patterns/SingletonPattern.java index 04b42c48..f6d884d9 100644 --- a/patterns/SingletonPattern.java +++ b/patterns/SingletonPattern.java @@ -1,4 +1,4 @@ -//: patterns/SingletonPattern.java +// patterns/SingletonPattern.java // ©2015 MindView LLC: see Copyright.txt // The Singleton design pattern: you can // never instantiate more than one. @@ -30,7 +30,8 @@ public class SingletonPattern { // Singleton s3 = (Singleton)s2.clone(); } catch(Exception e) {} } -} /* Output: +} +/* Output: 47 9 -*///:~ +*/ diff --git a/patterns/StateDemo.java b/patterns/StateDemo.java index a986ebcc..5232fcb9 100644 --- a/patterns/StateDemo.java +++ b/patterns/StateDemo.java @@ -1,4 +1,4 @@ -//: patterns/StateDemo.java +// patterns/StateDemo.java // ©2015 MindView LLC: see Copyright.txt // Simple demonstration of the State pattern. import static com.mindviewinc.util.Print.*; @@ -75,11 +75,12 @@ public class StateDemo { b.changeImp(new Implementation2()); test(b); } -} /* Output: +} +/* Output: Implementation1.f() Implementation1.g() Implementation1.h() Implementation2.f() Implementation2.g() Implementation2.h() -*///:~ +*/ diff --git a/patterns/TemplateMethod.java b/patterns/TemplateMethod.java index e956370a..803eaa43 100644 --- a/patterns/TemplateMethod.java +++ b/patterns/TemplateMethod.java @@ -1,4 +1,4 @@ -//: patterns/TemplateMethod.java +// patterns/TemplateMethod.java // ©2015 MindView LLC: see Copyright.txt // Simple demonstration of Template Method. @@ -33,10 +33,11 @@ public class TemplateMethod { public static void main(String args[]) { new MyApp(); } -} /* Output: +} +/* Output: Hello World! Hello World! Hello World! Hello World! Hello World! -*///:~ +*/ diff --git a/patterns/absfactory/GameEnvironment.java b/patterns/absfactory/GameEnvironment.java index 1c0758ed..87d852fe 100644 --- a/patterns/absfactory/GameEnvironment.java +++ b/patterns/absfactory/GameEnvironment.java @@ -1,4 +1,4 @@ -//: patterns/absfactory/GameEnvironment.java +// patterns/absfactory/GameEnvironment.java // ©2015 MindView LLC: see Copyright.txt // An example of the Abstract Factory pattern. package patterns.absfactory; @@ -93,7 +93,8 @@ public class GameEnvironment { g1.play(); g2.play(); } -} /* Output: +} +/* Output: Kitty has encountered a Puzzle KungFuGuy now battles a NastyWeapon -*///:~ +*/ diff --git a/patterns/absfactory/GameEnvironment2.java b/patterns/absfactory/GameEnvironment2.java index ff4b795f..00c6d6ce 100644 --- a/patterns/absfactory/GameEnvironment2.java +++ b/patterns/absfactory/GameEnvironment2.java @@ -1,4 +1,4 @@ -//: patterns/absfactory/GameEnvironment2.java +// patterns/absfactory/GameEnvironment2.java // ©2015 MindView LLC: see Copyright.txt // Using the Supplier<> Functional Interface. package patterns.absfactory; @@ -47,7 +47,8 @@ public class GameEnvironment2 { g1.play(); g2.play(); } -} /* Output: +} +/* Output: Kitty has encountered a Puzzle KungFuGuy now battles a NastyWeapon -*///:~ +*/ diff --git a/patterns/adapt/Adapter.java b/patterns/adapt/Adapter.java index 8ef9ebe9..204704be 100644 --- a/patterns/adapt/Adapter.java +++ b/patterns/adapt/Adapter.java @@ -1,4 +1,4 @@ -//: patterns/adapt/Adapter.java +// patterns/adapt/Adapter.java // ©2015 MindView LLC: see Copyright.txt // Variations on the Adapter pattern. package patterns.adapt; @@ -79,4 +79,5 @@ public class Adapter { WhatIHave3 whatIHave3 = new WhatIHave3(); whatIUse.op(whatIHave3.whatIWant()); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/patterns/chain/ChainOfResponsibility.java b/patterns/chain/ChainOfResponsibility.java index 00a3868d..298b65fb 100644 --- a/patterns/chain/ChainOfResponsibility.java +++ b/patterns/chain/ChainOfResponsibility.java @@ -1,4 +1,4 @@ -//: patterns/chain/ChainOfResponsibility.java +// patterns/chain/ChainOfResponsibility.java // ©2015 MindView LLC: see Copyright.txt package patterns.chain; import java.util.*; @@ -84,9 +84,10 @@ public class ChainOfResponsibility { else System.out.println("No algorithm found"); } -} /* Output: +} +/* Output: LeastSquares.algorithm Perturbation.algorithm Bisection.algorithm 5.5, 6.6 -*///:~ +*/ diff --git a/patterns/chain/ChainOfResponsibility2.java b/patterns/chain/ChainOfResponsibility2.java index 0205f44e..f61301b9 100644 --- a/patterns/chain/ChainOfResponsibility2.java +++ b/patterns/chain/ChainOfResponsibility2.java @@ -1,4 +1,4 @@ -//: patterns/chain/ChainOfResponsibility2.java +// patterns/chain/ChainOfResponsibility2.java // ©2015 MindView LLC: see Copyright.txt // Using the Functional interface. package patterns.chain; @@ -59,9 +59,10 @@ public class ChainOfResponsibility2 { else System.out.println("No algorithm found"); } -} /* Output: +} +/* Output: LeastSquares.algorithm Perturbation.algorithm Bisection.algorithm 5.5, 6.6 -*///:~ +*/ diff --git a/patterns/doubledispatch/DDAluminum.java b/patterns/doubledispatch/DDAluminum.java index ac44e19d..01c098d3 100644 --- a/patterns/doubledispatch/DDAluminum.java +++ b/patterns/doubledispatch/DDAluminum.java @@ -1,4 +1,4 @@ -//: patterns/doubledispatch/DDAluminum.java +// patterns/doubledispatch/DDAluminum.java // ©2015 MindView LLC: see Copyright.txt // Aluminum for double dispatching. package patterns.doubledispatch; @@ -16,4 +16,4 @@ public class DDAluminum extends Aluminum } return false; } -} ///:~ +} diff --git a/patterns/doubledispatch/DDCardboard.java b/patterns/doubledispatch/DDCardboard.java index ab388023..2062218f 100644 --- a/patterns/doubledispatch/DDCardboard.java +++ b/patterns/doubledispatch/DDCardboard.java @@ -1,4 +1,4 @@ -//: patterns/doubledispatch/DDCardboard.java +// patterns/doubledispatch/DDCardboard.java // ©2015 MindView LLC: see Copyright.txt // Cardboard for double dispatching. package patterns.doubledispatch; @@ -16,4 +16,4 @@ public class DDCardboard extends Cardboard } return false; } -} ///:~ +} diff --git a/patterns/doubledispatch/DDGlass.java b/patterns/doubledispatch/DDGlass.java index 43f48954..53bc9258 100644 --- a/patterns/doubledispatch/DDGlass.java +++ b/patterns/doubledispatch/DDGlass.java @@ -1,4 +1,4 @@ -//: patterns/doubledispatch/DDGlass.java +// patterns/doubledispatch/DDGlass.java // ©2015 MindView LLC: see Copyright.txt // Glass for double dispatching. package patterns.doubledispatch; @@ -16,4 +16,4 @@ public class DDGlass extends Glass } return false; } -} ///:~ +} diff --git a/patterns/doubledispatch/DDPaper.java b/patterns/doubledispatch/DDPaper.java index d575f1db..4ac8b429 100644 --- a/patterns/doubledispatch/DDPaper.java +++ b/patterns/doubledispatch/DDPaper.java @@ -1,4 +1,4 @@ -//: patterns/doubledispatch/DDPaper.java +// patterns/doubledispatch/DDPaper.java // ©2015 MindView LLC: see Copyright.txt // Paper for double dispatching. package patterns.doubledispatch; @@ -16,4 +16,4 @@ public class DDPaper extends Paper } return false; } -} ///:~ +} diff --git a/patterns/doubledispatch/DDTrash.dat b/patterns/doubledispatch/DDTrash.dat index b1153b21..c2b3501d 100644 --- a/patterns/doubledispatch/DDTrash.dat +++ b/patterns/doubledispatch/DDTrash.dat @@ -1,3 +1,4 @@ +// patterns/doubledispatch/DDTrash.dat patterns.doubledispatch.DDGlass:54 patterns.doubledispatch.DDPaper:22 patterns.doubledispatch.DDPaper:11 @@ -32,4 +33,3 @@ patterns.doubledispatch.DDGlass:60 patterns.doubledispatch.DDPaper:66 patterns.doubledispatch.DDAluminum:36 patterns.doubledispatch.DDCardboard:22 - diff --git a/patterns/doubledispatch/DoubleDispatch.java b/patterns/doubledispatch/DoubleDispatch.java index c75ad2e3..808d62e6 100644 --- a/patterns/doubledispatch/DoubleDispatch.java +++ b/patterns/doubledispatch/DoubleDispatch.java @@ -1,4 +1,4 @@ -//: patterns/doubledispatch/DoubleDispatch.java +// patterns/doubledispatch/DoubleDispatch.java // ©2015 MindView LLC: see Copyright.txt // Using multiple dispatching to handle more // than one unknown type during a method call. @@ -66,7 +66,8 @@ public class DoubleDispatch { // ... and for the master bin Trash.sumValue(bin); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Loading patterns.doubledispatch.DDGlass Loading patterns.doubledispatch.DDPaper Loading patterns.doubledispatch.DDAluminum @@ -88,4 +89,4 @@ weight of patterns.doubledispatch.DDPaper = 66.0 weight of patterns.doubledispatch.DDAluminum = 36.0 weight of patterns.doubledispatch.DDCardboard = 22.0 Total value = 1086.0599818825722 -*///:~ +*/ diff --git a/patterns/doubledispatch/TypedBin.java b/patterns/doubledispatch/TypedBin.java index 2165d394..83dcece6 100644 --- a/patterns/doubledispatch/TypedBin.java +++ b/patterns/doubledispatch/TypedBin.java @@ -1,4 +1,4 @@ -//: patterns/doubledispatch/TypedBin.java +// patterns/doubledispatch/TypedBin.java // ©2015 MindView LLC: see Copyright.txt // An ArrayList that can grab the right type. package patterns.doubledispatch; @@ -26,4 +26,4 @@ public abstract class TypedBin { public boolean add(DDCardboard a) { return false; } -} ///:~ +} diff --git a/patterns/doubledispatch/TypedBinMember.java b/patterns/doubledispatch/TypedBinMember.java index 766d8303..134b1d14 100644 --- a/patterns/doubledispatch/TypedBinMember.java +++ b/patterns/doubledispatch/TypedBinMember.java @@ -1,4 +1,4 @@ -//: patterns/doubledispatch/TypedBinMember.java +// patterns/doubledispatch/TypedBinMember.java // ©2015 MindView LLC: see Copyright.txt // An interface for adding the double dispatching // method to the trash hierarchy without @@ -8,4 +8,4 @@ package patterns.doubledispatch; interface TypedBinMember { // The new method: boolean addToBin(TypedBin[] tb); -} ///:~ +} diff --git a/patterns/dynatrash/DynaTrash.java b/patterns/dynatrash/DynaTrash.java index cce64934..47885a26 100644 --- a/patterns/dynatrash/DynaTrash.java +++ b/patterns/dynatrash/DynaTrash.java @@ -1,4 +1,4 @@ -//: patterns/dynatrash/DynaTrash.java +// patterns/dynatrash/DynaTrash.java // ©2015 MindView LLC: see Copyright.txt // Using a Map of Lists and RTTI // to automatically sort trash into @@ -50,7 +50,8 @@ public class DynaTrash { while(keys.hasNext()) Trash.sumValue(bin.get(keys.next())); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Loading patterns.trash.Glass Loading patterns.trash.Paper Loading patterns.trash.Aluminum @@ -72,4 +73,4 @@ weight of patterns.trash.Paper = 91.0 weight of patterns.trash.Paper = 80.0 weight of patterns.trash.Paper = 66.0 Total value = 35.80000053346157 -*///:~ +*/ diff --git a/patterns/dynatrash/Trash.dat b/patterns/dynatrash/Trash.dat index afa62480..59ae3cd6 100644 --- a/patterns/dynatrash/Trash.dat +++ b/patterns/dynatrash/Trash.dat @@ -1,3 +1,4 @@ +// patterns/recycleap/Trash.dat patterns.trash.Glass:54 patterns.trash.Paper:22 patterns.trash.Paper:11 @@ -32,4 +33,3 @@ patterns.trash.Glass:60 patterns.trash.Paper:66 patterns.trash.Aluminum:36 patterns.trash.Cardboard:22 - diff --git a/patterns/factory/ShapeFactory1.java b/patterns/factory/ShapeFactory1.java index f06f9969..5926442f 100644 --- a/patterns/factory/ShapeFactory1.java +++ b/patterns/factory/ShapeFactory1.java @@ -1,4 +1,4 @@ -//: patterns/factory/ShapeFactory1.java +// patterns/factory/ShapeFactory1.java // ©2015 MindView LLC: see Copyright.txt // A simple static factory method. package patterns.factory; @@ -56,7 +56,8 @@ public class ShapeFactory1 { shapes.forEach(Shape::draw); shapes.forEach(Shape::erase); } -} /* Output: +} +/* Output: Circle.draw Square.draw Square.draw @@ -69,4 +70,4 @@ Square.erase Circle.erase Circle.erase Square.erase -*///:~ +*/ diff --git a/patterns/observer/ObservedFlower.java b/patterns/observer/ObservedFlower.java index c18c6afb..91e83276 100644 --- a/patterns/observer/ObservedFlower.java +++ b/patterns/observer/ObservedFlower.java @@ -1,4 +1,4 @@ -//: patterns/observer/ObservedFlower.java +// patterns/observer/ObservedFlower.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of "observer" pattern. package patterns.observer; @@ -141,7 +141,8 @@ public class ObservedFlower { f.open(); f.close(); } -} /* Output: +} +/* Output: Bee B's breakfast time! Bee A's breakfast time! Hummingbird A's breakfast time! @@ -151,4 +152,4 @@ Hummingbird A's bed time! Bee B's bed time! Hummingbird B's bed time! Hummingbird A's bed time! -*///:~ +*/ diff --git a/patterns/recyclea/RecycleA.java b/patterns/recyclea/RecycleA.java index a0b48c85..ea9ee06e 100644 --- a/patterns/recyclea/RecycleA.java +++ b/patterns/recyclea/RecycleA.java @@ -1,4 +1,4 @@ -//: patterns/recyclea/RecycleA.java +// patterns/recyclea/RecycleA.java // ©2015 MindView LLC: see Copyright.txt // Recycling with RTTI. package patterns.recyclea; @@ -92,7 +92,8 @@ public class RecycleA { Trash.sumValue(glassBin); Trash.sumValue(bin); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) weight of patterns.recyclea.Aluminum = 97.49879461494744 weight of patterns.recyclea.Aluminum = 99.60561944523387 weight of patterns.recyclea.Aluminum = 93.10883063826067 @@ -114,4 +115,4 @@ weight of patterns.recyclea.Glass = 50.356208994386385 weight of patterns.recyclea.Paper = 89.7955125865738 weight of patterns.recyclea.Paper = 32.73979803583131 Total value = 1101.1015429445522 -*///:~ +*/ diff --git a/patterns/recycleap/RecycleAP.java b/patterns/recycleap/RecycleAP.java index 609c244a..40a667db 100644 --- a/patterns/recycleap/RecycleAP.java +++ b/patterns/recycleap/RecycleAP.java @@ -1,4 +1,4 @@ -//: patterns/recycleap/RecycleAP.java +// patterns/recycleap/RecycleAP.java // ©2015 MindView LLC: see Copyright.txt // Recycling with RTTI and Prototypes. package patterns.recycleap; @@ -28,7 +28,8 @@ public class RecycleAP { Trash.sumValue(glassBin); Trash.sumValue(bin); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Loading patterns.trash.Glass Loading patterns.trash.Paper Loading patterns.trash.Aluminum @@ -50,4 +51,4 @@ weight of patterns.trash.Paper = 66.0 weight of patterns.trash.Aluminum = 36.0 weight of patterns.trash.Cardboard = 22.0 Total value = 1086.0599818825722 -*///:~ +*/ diff --git a/patterns/recycleap/Trash.dat b/patterns/recycleap/Trash.dat index afa62480..59ae3cd6 100644 --- a/patterns/recycleap/Trash.dat +++ b/patterns/recycleap/Trash.dat @@ -1,3 +1,4 @@ +// patterns/recycleap/Trash.dat patterns.trash.Glass:54 patterns.trash.Paper:22 patterns.trash.Paper:11 @@ -32,4 +33,3 @@ patterns.trash.Glass:60 patterns.trash.Paper:66 patterns.trash.Aluminum:36 patterns.trash.Cardboard:22 - diff --git a/patterns/recycleb/RecycleB.java b/patterns/recycleb/RecycleB.java index b0593c57..cc4e7545 100644 --- a/patterns/recycleb/RecycleB.java +++ b/patterns/recycleb/RecycleB.java @@ -1,4 +1,4 @@ -//: patterns/recycleb/RecycleB.java +// patterns/recycleb/RecycleB.java // ©2015 MindView LLC: see Copyright.txt // Adding more objects to the recycling problem. package patterns.recycleb; @@ -55,7 +55,8 @@ public class RecycleB { trashBins.forEach(Trash::sumValue); Trash.sumValue(bin); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Loading patterns.trash.Glass Loading patterns.trash.Paper Loading patterns.trash.Aluminum @@ -77,4 +78,4 @@ weight of patterns.trash.Paper = 66.0 weight of patterns.trash.Aluminum = 36.0 weight of patterns.trash.Cardboard = 22.0 Total value = 1086.0599818825722 -*///:~ +*/ diff --git a/patterns/recycleb/Trash.dat b/patterns/recycleb/Trash.dat index afa62480..59ae3cd6 100644 --- a/patterns/recycleb/Trash.dat +++ b/patterns/recycleb/Trash.dat @@ -1,3 +1,4 @@ +// patterns/recycleap/Trash.dat patterns.trash.Glass:54 patterns.trash.Paper:22 patterns.trash.Paper:11 @@ -32,4 +33,3 @@ patterns.trash.Glass:60 patterns.trash.Paper:66 patterns.trash.Aluminum:36 patterns.trash.Cardboard:22 - diff --git a/patterns/state/StateMachineDemo.java b/patterns/state/StateMachineDemo.java index e6bc6d8d..b7c71589 100644 --- a/patterns/state/StateMachineDemo.java +++ b/patterns/state/StateMachineDemo.java @@ -1,4 +1,4 @@ -//: patterns/state/StateMachineDemo.java +// patterns/state/StateMachineDemo.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates StateMachine pattern // and Template method. @@ -74,9 +74,10 @@ public class StateMachineDemo { public static void main(String args[]) { new Washer(); } -} /* Output: +} +/* Output: Washing Spinning Rinsing Spinning -*///:~ +*/ diff --git a/patterns/strategy/StrategyPattern.java b/patterns/strategy/StrategyPattern.java index e40c9d05..654c46c9 100644 --- a/patterns/strategy/StrategyPattern.java +++ b/patterns/strategy/StrategyPattern.java @@ -1,4 +1,4 @@ -//: patterns/strategy/StrategyPattern.java +// patterns/strategy/StrategyPattern.java // ©2015 MindView LLC: see Copyright.txt package patterns.strategy; import java.util.function.*; @@ -54,7 +54,8 @@ public class StrategyPattern { solver.changeAlgorithm(new Bisection()); printArray(solver.minima(line)); } -} /* Output: +} +/* Output: 1.1, 2.2 5.5, 6.6 -*///:~ +*/ diff --git a/patterns/strategy/StrategyPattern2.java b/patterns/strategy/StrategyPattern2.java index 71ee4f69..a22f49a5 100644 --- a/patterns/strategy/StrategyPattern2.java +++ b/patterns/strategy/StrategyPattern2.java @@ -1,4 +1,4 @@ -//: patterns/strategy/StrategyPattern2.java +// patterns/strategy/StrategyPattern2.java // ©2015 MindView LLC: see Copyright.txt package patterns.strategy; import java.util.function.*; @@ -33,7 +33,8 @@ public class StrategyPattern2 { solver.bisection(); printArray(solver.minima(line)); } -} /* Output: +} +/* Output: 1.1, 2.2 5.5, 6.6 -*///:~ +*/ diff --git a/patterns/trash/Aluminum.java b/patterns/trash/Aluminum.java index e5a1ac8e..cba82122 100644 --- a/patterns/trash/Aluminum.java +++ b/patterns/trash/Aluminum.java @@ -1,4 +1,4 @@ -//: patterns/trash/Aluminum.java +// patterns/trash/Aluminum.java // ©2015 MindView LLC: see Copyright.txt // The Aluminum class with prototyping. package patterns.trash; @@ -11,4 +11,4 @@ public class Aluminum extends Trash { public static void value(double newVal) { val = newVal; } -} ///:~ +} diff --git a/patterns/trash/Cardboard.java b/patterns/trash/Cardboard.java index a1ec0b20..c48954d5 100644 --- a/patterns/trash/Cardboard.java +++ b/patterns/trash/Cardboard.java @@ -1,4 +1,4 @@ -//: patterns/trash/Cardboard.java +// patterns/trash/Cardboard.java // ©2015 MindView LLC: see Copyright.txt // The Cardboard class with prototyping. package patterns.trash; @@ -11,4 +11,4 @@ public class Cardboard extends Trash { public static void value(double newVal) { val = newVal; } -} ///:~ +} diff --git a/patterns/trash/Fillable.java b/patterns/trash/Fillable.java index d5f8dbb4..29c6e7e1 100644 --- a/patterns/trash/Fillable.java +++ b/patterns/trash/Fillable.java @@ -1,8 +1,8 @@ -//: patterns/trash/Fillable.java +// patterns/trash/Fillable.java // ©2015 MindView LLC: see Copyright.txt // Any object that can be filled with Trash. package patterns.trash; public interface Fillable { void addTrash(T t); -} ///:~ +} diff --git a/patterns/trash/FillableList.java b/patterns/trash/FillableList.java index c4a32998..1c7f6785 100644 --- a/patterns/trash/FillableList.java +++ b/patterns/trash/FillableList.java @@ -1,4 +1,4 @@ -//: patterns/trash/FillableList.java +// patterns/trash/FillableList.java // ©2015 MindView LLC: see Copyright.txt // Adapter that makes an ArrayList Fillable. package patterns.trash; @@ -12,4 +12,4 @@ implements Fillable { } @Override public void addTrash(T t) { v.add(t); } -} ///:~ +} diff --git a/patterns/trash/Glass.java b/patterns/trash/Glass.java index 1700f3f2..c6133e88 100644 --- a/patterns/trash/Glass.java +++ b/patterns/trash/Glass.java @@ -1,4 +1,4 @@ -//: patterns/trash/Glass.java +// patterns/trash/Glass.java // ©2015 MindView LLC: see Copyright.txt // The Glass class with prototyping. package patterns.trash; @@ -11,4 +11,4 @@ public class Glass extends Trash { public static void value(double newVal) { val = newVal; } -} ///:~ +} diff --git a/patterns/trash/Paper.java b/patterns/trash/Paper.java index 9aeb52a2..74f645cd 100644 --- a/patterns/trash/Paper.java +++ b/patterns/trash/Paper.java @@ -1,4 +1,4 @@ -//: patterns/trash/Paper.java +// patterns/trash/Paper.java // ©2015 MindView LLC: see Copyright.txt // The Paper class with prototyping. package patterns.trash; @@ -11,4 +11,4 @@ public class Paper extends Trash { public static void value(double newVal) { val = newVal; } -} ///:~ +} diff --git a/patterns/trash/ParseTrash.java b/patterns/trash/ParseTrash.java index 5ab52f64..7e6dbae6 100644 --- a/patterns/trash/ParseTrash.java +++ b/patterns/trash/ParseTrash.java @@ -1,4 +1,4 @@ -//: patterns/trash/ParseTrash.java +// patterns/trash/ParseTrash.java // ©2015 MindView LLC: see Copyright.txt // Open a file and parse its contents into // Trash objects, placing each into an ArrayList. @@ -37,4 +37,4 @@ public class ParseTrash { fillBin(String filename, ArrayList bin) { fillBin(filename, new FillableList<>(bin)); } -} ///:~ +} diff --git a/patterns/trash/Trash.java b/patterns/trash/Trash.java index e082d2ba..f9424b2e 100644 --- a/patterns/trash/Trash.java +++ b/patterns/trash/Trash.java @@ -1,4 +1,4 @@ -//: patterns/trash/Trash.java +// patterns/trash/Trash.java // ©2015 MindView LLC: see Copyright.txt // Base class for Trash recycling examples. package patterns.trash; @@ -83,4 +83,4 @@ public abstract class Trash { this.data = data; } } -} ///:~ +} diff --git a/patterns/trashvisitor/TrashVisitor.java b/patterns/trashvisitor/TrashVisitor.java index e544e850..8653a362 100644 --- a/patterns/trashvisitor/TrashVisitor.java +++ b/patterns/trashvisitor/TrashVisitor.java @@ -1,4 +1,4 @@ -//: patterns/trashvisitor/TrashVisitor.java +// patterns/trashvisitor/TrashVisitor.java // ©2015 MindView LLC: see Copyright.txt // The "visitor" pattern. package patterns.trashvisitor; @@ -96,7 +96,8 @@ public class TrashVisitor { pv.total(); wv.total(); } -} /* Output: (First and last 10 Lines) +} +/* Output: (First and last 10 Lines) Loading patterns.trashvisitor.VGlass Loading patterns.trashvisitor.VPaper Loading patterns.trashvisitor.VAluminum @@ -118,4 +119,4 @@ Total weight Aluminum:515.0 Total weight Paper:358.0 Total weight Glass:653.0 Total weight Cardboard:174.0 -*///:~ +*/ diff --git a/patterns/trashvisitor/VAluminum.java b/patterns/trashvisitor/VAluminum.java index 175501cb..f30dbef2 100644 --- a/patterns/trashvisitor/VAluminum.java +++ b/patterns/trashvisitor/VAluminum.java @@ -1,4 +1,4 @@ -//: patterns/trashvisitor/VAluminum.java +// patterns/trashvisitor/VAluminum.java // ©2015 MindView LLC: see Copyright.txt // Aluminum for the visitor pattern. package patterns.trashvisitor; @@ -11,4 +11,4 @@ public class VAluminum extends Aluminum public void accept(Visitor v) { v.visit(this); } -} ///:~ +} diff --git a/patterns/trashvisitor/VCardboard.java b/patterns/trashvisitor/VCardboard.java index f5c70968..fa9acd33 100644 --- a/patterns/trashvisitor/VCardboard.java +++ b/patterns/trashvisitor/VCardboard.java @@ -1,4 +1,4 @@ -//: patterns/trashvisitor/VCardboard.java +// patterns/trashvisitor/VCardboard.java // ©2015 MindView LLC: see Copyright.txt // Cardboard for the visitor pattern. package patterns.trashvisitor; @@ -11,4 +11,4 @@ public class VCardboard extends Cardboard public void accept(Visitor v) { v.visit(this); } -} ///:~ +} diff --git a/patterns/trashvisitor/VGlass.java b/patterns/trashvisitor/VGlass.java index 5dbce38f..0b76fe3e 100644 --- a/patterns/trashvisitor/VGlass.java +++ b/patterns/trashvisitor/VGlass.java @@ -1,4 +1,4 @@ -//: patterns/trashvisitor/VGlass.java +// patterns/trashvisitor/VGlass.java // ©2015 MindView LLC: see Copyright.txt // Glass for the visitor pattern. package patterns.trashvisitor; @@ -11,4 +11,4 @@ public class VGlass extends Glass public void accept(Visitor v) { v.visit(this); } -} ///:~ +} diff --git a/patterns/trashvisitor/VPaper.java b/patterns/trashvisitor/VPaper.java index 5f8701a0..3a8bfe7f 100644 --- a/patterns/trashvisitor/VPaper.java +++ b/patterns/trashvisitor/VPaper.java @@ -1,4 +1,4 @@ -//: patterns/trashvisitor/VPaper.java +// patterns/trashvisitor/VPaper.java // ©2015 MindView LLC: see Copyright.txt // Paper for the visitor pattern. package patterns.trashvisitor; @@ -11,4 +11,4 @@ public class VPaper extends Paper public void accept(Visitor v) { v.visit(this); } -} ///:~ +} diff --git a/patterns/trashvisitor/VTrash.dat b/patterns/trashvisitor/VTrash.dat index bcde40b6..9bcc1ef5 100644 --- a/patterns/trashvisitor/VTrash.dat +++ b/patterns/trashvisitor/VTrash.dat @@ -1,3 +1,4 @@ +// patterns/trashvisitor/VTrash.dat patterns.trashvisitor.VGlass:54 patterns.trashvisitor.VPaper:22 patterns.trashvisitor.VPaper:11 @@ -32,4 +33,3 @@ patterns.trashvisitor.VGlass:60 patterns.trashvisitor.VPaper:66 patterns.trashvisitor.VAluminum:36 patterns.trashvisitor.VCardboard:22 - diff --git a/patterns/trashvisitor/Visitable.java b/patterns/trashvisitor/Visitable.java index d7a837c4..402fd263 100644 --- a/patterns/trashvisitor/Visitable.java +++ b/patterns/trashvisitor/Visitable.java @@ -1,4 +1,4 @@ -//: patterns/trashvisitor/Visitable.java +// patterns/trashvisitor/Visitable.java // ©2015 MindView LLC: see Copyright.txt // An interface to add visitor functionality to // the Trash hierarchy without modifying the @@ -8,4 +8,4 @@ package patterns.trashvisitor; interface Visitable { // The new method: void accept(Visitor v); -} ///:~ +} diff --git a/patterns/trashvisitor/Visitor.java b/patterns/trashvisitor/Visitor.java index 80302c70..059bcd48 100644 --- a/patterns/trashvisitor/Visitor.java +++ b/patterns/trashvisitor/Visitor.java @@ -1,4 +1,4 @@ -//: patterns/trashvisitor/Visitor.java +// patterns/trashvisitor/Visitor.java // ©2015 MindView LLC: see Copyright.txt // The base interface for visitors. package patterns.trashvisitor; @@ -8,4 +8,4 @@ interface Visitor { void visit(VPaper p); void visit(VGlass g); void visit(VCardboard c); -} ///:~ +} diff --git a/patterns/visitor/BeeAndFlowers.java b/patterns/visitor/BeeAndFlowers.java index 5e738471..b59a14d4 100644 --- a/patterns/visitor/BeeAndFlowers.java +++ b/patterns/visitor/BeeAndFlowers.java @@ -1,4 +1,4 @@ -//: patterns/visitor/BeeAndFlowers.java +// patterns/visitor/BeeAndFlowers.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of "visitor" pattern. package patterns.visitor; @@ -93,7 +93,8 @@ public class BeeAndFlowers { while(it.hasNext()) it.next().accept(bee); } -} /* Output: +} +/* Output: Gladiolus Chrysanthemum Chrysanthemum @@ -114,4 +115,4 @@ Bee and Renuculus Bee and Renuculus Bee and Gladiolus Bee and Renuculus -*///:~ +*/ diff --git a/patterns/visualobserver/BoxObserver.java b/patterns/visualobserver/BoxObserver.java index 7190589a..494c29a1 100644 --- a/patterns/visualobserver/BoxObserver.java +++ b/patterns/visualobserver/BoxObserver.java @@ -1,4 +1,4 @@ -//: patterns/visualobserver/BoxObserver.java +// patterns/visualobserver/BoxObserver.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of Observer pattern using // Java's built-in observer classes. @@ -88,4 +88,5 @@ class OCBox extends JPanel implements Observer { return Math.abs(x - b.x) <= 1 && Math.abs(y - b.y) <= 1; } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/polymorphism/CovariantReturn.java b/polymorphism/CovariantReturn.java index 1da43fdb..e536ac20 100644 --- a/polymorphism/CovariantReturn.java +++ b/polymorphism/CovariantReturn.java @@ -1,4 +1,4 @@ -//: polymorphism/CovariantReturn.java +// polymorphism/CovariantReturn.java // ©2015 MindView LLC: see Copyright.txt class Grain { @@ -29,7 +29,8 @@ public class CovariantReturn { g = m.process(); System.out.println(g); } -} /* Output: +} +/* Output: Grain Wheat -*///:~ +*/ diff --git a/polymorphism/FieldAccess.java b/polymorphism/FieldAccess.java index 01370ab5..40f3bc15 100644 --- a/polymorphism/FieldAccess.java +++ b/polymorphism/FieldAccess.java @@ -1,4 +1,4 @@ -//: polymorphism/FieldAccess.java +// polymorphism/FieldAccess.java // ©2015 MindView LLC: see Copyright.txt // Direct field access is determined at compile time. @@ -26,7 +26,8 @@ public class FieldAccess { ", sub.getSuperField() = " + sub.getSuperField()); } -} /* Output: +} +/* Output: sup.field = 0, sup.getField() = 1 sub.field = 1, sub.getField() = 1, sub.getSuperField() = 0 -*///:~ +*/ diff --git a/polymorphism/Frog.java b/polymorphism/Frog.java index ffd17dcf..f4a4589f 100644 --- a/polymorphism/Frog.java +++ b/polymorphism/Frog.java @@ -1,4 +1,4 @@ -//: polymorphism/Frog.java +// polymorphism/Frog.java // ©2015 MindView LLC: see Copyright.txt // Cleanup and inheritance. package polymorphism; @@ -89,7 +89,8 @@ public class Frog extends Amphibian { print("Bye!"); frog.dispose(); } -} /* Output: +} +/* Output: Creating Characteristic is alive Creating Description Basic Living Creature LivingCreature() @@ -115,4 +116,4 @@ disposing Characteristic has heart LivingCreature dispose disposing Description Basic Living Creature disposing Characteristic is alive -*///:~ +*/ diff --git a/polymorphism/PolyConstructors.java b/polymorphism/PolyConstructors.java index 0ac4fbb6..ab7ff437 100644 --- a/polymorphism/PolyConstructors.java +++ b/polymorphism/PolyConstructors.java @@ -1,4 +1,4 @@ -//: polymorphism/PolyConstructors.java +// polymorphism/PolyConstructors.java // ©2015 MindView LLC: see Copyright.txt // Constructors and polymorphism // don't produce what you might expect. @@ -29,9 +29,10 @@ public class PolyConstructors { public static void main(String[] args) { new RoundGlyph(5); } -} /* Output: +} +/* Output: Glyph() before draw() RoundGlyph.draw(), radius = 0 Glyph() after draw() RoundGlyph.RoundGlyph(), radius = 5 -*///:~ +*/ diff --git a/polymorphism/PrivateOverride.java b/polymorphism/PrivateOverride.java index e3fdba28..c84c2aff 100644 --- a/polymorphism/PrivateOverride.java +++ b/polymorphism/PrivateOverride.java @@ -1,4 +1,4 @@ -//: polymorphism/PrivateOverride.java +// polymorphism/PrivateOverride.java // ©2015 MindView LLC: see Copyright.txt // Trying to override a private method. package polymorphism; @@ -14,6 +14,7 @@ public class PrivateOverride { class Derived extends PrivateOverride { public void f() { print("public f()"); } -} /* Output: +} +/* Output: private f() -*///:~ +*/ diff --git a/polymorphism/RTTI.java b/polymorphism/RTTI.java index 722a6842..d39ad5ec 100644 --- a/polymorphism/RTTI.java +++ b/polymorphism/RTTI.java @@ -1,4 +1,4 @@ -//: polymorphism/RTTI.java +// polymorphism/RTTI.java // ©2015 MindView LLC: see Copyright.txt // Downcasting & Runtime type information (RTTI). // {ThrowsException} @@ -31,10 +31,11 @@ public class RTTI { ((MoreUseful)x[1]).u(); // Downcast/RTTI ((MoreUseful)x[0]).u(); // Exception thrown } -} /* Output: +} +/* Output: ___[ Error Output ]___ Exception in thread "main" java.lang.ClassCastException: Useful cannot be cast to MoreUseful at RTTI.main(RTTI.java:31) ___[ Exception is Expected ]___ -*///:~ +*/ diff --git a/polymorphism/ReferenceCounting.java b/polymorphism/ReferenceCounting.java index 0371d78f..0b2860f1 100644 --- a/polymorphism/ReferenceCounting.java +++ b/polymorphism/ReferenceCounting.java @@ -1,4 +1,4 @@ -//: polymorphism/ReferenceCounting.java +// polymorphism/ReferenceCounting.java // ©2015 MindView LLC: see Copyright.txt // Cleaning up shared member objects. import static com.mindviewinc.util.Print.*; @@ -45,7 +45,8 @@ public class ReferenceCounting { for(Composing c : composing) c.dispose(); } -} /* Output: +} +/* Output: Creating Shared 0 Creating Composing 0 Creating Composing 1 @@ -58,4 +59,4 @@ disposing Composing 2 disposing Composing 3 disposing Composing 4 Disposing Shared 0 -*///:~ +*/ diff --git a/polymorphism/Sandwich.java b/polymorphism/Sandwich.java index ba4ba562..c8eeffe8 100644 --- a/polymorphism/Sandwich.java +++ b/polymorphism/Sandwich.java @@ -1,4 +1,4 @@ -//: polymorphism/Sandwich.java +// polymorphism/Sandwich.java // ©2015 MindView LLC: see Copyright.txt // Order of constructor calls. package polymorphism; @@ -36,7 +36,8 @@ public class Sandwich extends PortableLunch { public static void main(String[] args) { new Sandwich(); } -} /* Output: +} +/* Output: Meal() Lunch() PortableLunch() @@ -44,4 +45,4 @@ Bread() Cheese() Lettuce() Sandwich() -*///:~ +*/ diff --git a/polymorphism/Shapes.java b/polymorphism/Shapes.java index 5632bfbd..b0ad4b80 100644 --- a/polymorphism/Shapes.java +++ b/polymorphism/Shapes.java @@ -1,4 +1,4 @@ -//: polymorphism/Shapes.java +// polymorphism/Shapes.java // ©2015 MindView LLC: see Copyright.txt // Polymorphism in Java. import polymorphism.shape.*; @@ -15,7 +15,8 @@ public class Shapes { for(Shape shp : s) shp.draw(); } -} /* Output: +} +/* Output: Triangle.draw() Triangle.draw() Square.draw() @@ -25,4 +26,4 @@ Triangle.draw() Square.draw() Triangle.draw() Circle.draw() -*///:~ +*/ diff --git a/polymorphism/StaticPolymorphism.java b/polymorphism/StaticPolymorphism.java index 7e063d86..90630424 100644 --- a/polymorphism/StaticPolymorphism.java +++ b/polymorphism/StaticPolymorphism.java @@ -1,4 +1,4 @@ -//: polymorphism/StaticPolymorphism.java +// polymorphism/StaticPolymorphism.java // ©2015 MindView LLC: see Copyright.txt // Static methods are not polymorphic. @@ -27,7 +27,8 @@ public class StaticPolymorphism { System.out.println(StaticSuper.staticGet()); System.out.println(sup.dynamicGet()); } -} /* Output: +} +/* Output: Base staticGet() Derived dynamicGet() -*///:~ +*/ diff --git a/polymorphism/Transmogrify.java b/polymorphism/Transmogrify.java index 0cb228f0..259af1c0 100644 --- a/polymorphism/Transmogrify.java +++ b/polymorphism/Transmogrify.java @@ -1,4 +1,4 @@ -//: polymorphism/Transmogrify.java +// polymorphism/Transmogrify.java // ©2015 MindView LLC: see Copyright.txt // Dynamically changing the behavior of an object // via composition (the "State" design pattern). @@ -31,7 +31,8 @@ public class Transmogrify { stage.change(); stage.performPlay(); } -} /* Output: +} +/* Output: HappyActor SadActor -*///:~ +*/ diff --git a/polymorphism/music/Instrument.java b/polymorphism/music/Instrument.java index 63124a4c..513897b0 100644 --- a/polymorphism/music/Instrument.java +++ b/polymorphism/music/Instrument.java @@ -1,4 +1,4 @@ -//: polymorphism/music/Instrument.java +// polymorphism/music/Instrument.java // ©2015 MindView LLC: see Copyright.txt package polymorphism.music; import static com.mindviewinc.util.Print.*; @@ -7,4 +7,4 @@ class Instrument { public void play(Note n) { print("Instrument.play()"); } -} ///:~ +} diff --git a/polymorphism/music/Music.java b/polymorphism/music/Music.java index 0f90f776..05ab0dbf 100644 --- a/polymorphism/music/Music.java +++ b/polymorphism/music/Music.java @@ -1,4 +1,4 @@ -//: polymorphism/music/Music.java +// polymorphism/music/Music.java // ©2015 MindView LLC: see Copyright.txt // Inheritance & upcasting. package polymorphism.music; @@ -12,6 +12,7 @@ public class Music { Wind flute = new Wind(); tune(flute); // Upcasting } -} /* Output: +} +/* Output: Wind.play() MIDDLE_C -*///:~ +*/ diff --git a/polymorphism/music/Music2.java b/polymorphism/music/Music2.java index 558f5172..84476130 100644 --- a/polymorphism/music/Music2.java +++ b/polymorphism/music/Music2.java @@ -1,4 +1,4 @@ -//: polymorphism/music/Music2.java +// polymorphism/music/Music2.java // ©2015 MindView LLC: see Copyright.txt // Overloading instead of upcasting. package polymorphism.music; @@ -36,8 +36,9 @@ public class Music2 { tune(violin); tune(frenchHorn); } -} /* Output: +} +/* Output: Wind.play() MIDDLE_C Stringed.play() MIDDLE_C Brass.play() MIDDLE_C -*///:~ +*/ diff --git a/polymorphism/music/Note.java b/polymorphism/music/Note.java index f39b7b98..96581a66 100644 --- a/polymorphism/music/Note.java +++ b/polymorphism/music/Note.java @@ -1,8 +1,8 @@ -//: polymorphism/music/Note.java +// polymorphism/music/Note.java // ©2015 MindView LLC: see Copyright.txt // Notes to play on musical instruments. package polymorphism.music; public enum Note { MIDDLE_C, C_SHARP, B_FLAT; // Etc. -} ///:~ +} diff --git a/polymorphism/music/Wind.java b/polymorphism/music/Wind.java index b49f2d2b..fbd9fe66 100644 --- a/polymorphism/music/Wind.java +++ b/polymorphism/music/Wind.java @@ -1,4 +1,4 @@ -//: polymorphism/music/Wind.java +// polymorphism/music/Wind.java // ©2015 MindView LLC: see Copyright.txt package polymorphism.music; @@ -10,4 +10,4 @@ public class Wind extends Instrument { public void play(Note n) { System.out.println("Wind.play() " + n); } -} ///:~ +} diff --git a/polymorphism/music3/Music3.java b/polymorphism/music3/Music3.java index f67d3c68..a308d80f 100644 --- a/polymorphism/music3/Music3.java +++ b/polymorphism/music3/Music3.java @@ -1,4 +1,4 @@ -//: polymorphism/music3/Music3.java +// polymorphism/music3/Music3.java // ©2015 MindView LLC: see Copyright.txt // An extensible program. package polymorphism.music3; @@ -74,10 +74,11 @@ public class Music3 { }; tuneAll(orchestra); } -} /* Output: +} +/* Output: Wind.play() MIDDLE_C Percussion.play() MIDDLE_C Stringed.play() MIDDLE_C Brass.play() MIDDLE_C Woodwind.play() MIDDLE_C -*///:~ +*/ diff --git a/polymorphism/shape/Circle.java b/polymorphism/shape/Circle.java index 42643c3a..c3a1cca6 100644 --- a/polymorphism/shape/Circle.java +++ b/polymorphism/shape/Circle.java @@ -1,4 +1,4 @@ -//: polymorphism/shape/Circle.java +// polymorphism/shape/Circle.java // ©2015 MindView LLC: see Copyright.txt package polymorphism.shape; import static com.mindviewinc.util.Print.*; @@ -8,4 +8,4 @@ public class Circle extends Shape { public void draw() { print("Circle.draw()"); } @Override public void erase() { print("Circle.erase()"); } -} ///:~ +} diff --git a/polymorphism/shape/RandomShapeGenerator.java b/polymorphism/shape/RandomShapeGenerator.java index f0e4559c..10c49054 100644 --- a/polymorphism/shape/RandomShapeGenerator.java +++ b/polymorphism/shape/RandomShapeGenerator.java @@ -1,4 +1,4 @@ -//: polymorphism/shape/RandomShapeGenerator.java +// polymorphism/shape/RandomShapeGenerator.java // ©2015 MindView LLC: see Copyright.txt // A "factory" that randomly creates shapes. package polymorphism.shape; @@ -14,4 +14,4 @@ public class RandomShapeGenerator { case 2: return new Triangle(); } } -} ///:~ +} diff --git a/polymorphism/shape/Shape.java b/polymorphism/shape/Shape.java index b19674f0..7849315a 100644 --- a/polymorphism/shape/Shape.java +++ b/polymorphism/shape/Shape.java @@ -1,8 +1,8 @@ -//: polymorphism/shape/Shape.java +// polymorphism/shape/Shape.java // ©2015 MindView LLC: see Copyright.txt package polymorphism.shape; public class Shape { public void draw() {} public void erase() {} -} ///:~ +} diff --git a/polymorphism/shape/Square.java b/polymorphism/shape/Square.java index a0777d31..c8351e03 100644 --- a/polymorphism/shape/Square.java +++ b/polymorphism/shape/Square.java @@ -1,4 +1,4 @@ -//: polymorphism/shape/Square.java +// polymorphism/shape/Square.java // ©2015 MindView LLC: see Copyright.txt package polymorphism.shape; import static com.mindviewinc.util.Print.*; @@ -8,4 +8,4 @@ public class Square extends Shape { public void draw() { print("Square.draw()"); } @Override public void erase() { print("Square.erase()"); } -} ///:~ +} diff --git a/polymorphism/shape/Triangle.java b/polymorphism/shape/Triangle.java index 418d014c..eec65ac0 100644 --- a/polymorphism/shape/Triangle.java +++ b/polymorphism/shape/Triangle.java @@ -1,4 +1,4 @@ -//: polymorphism/shape/Triangle.java +// polymorphism/shape/Triangle.java // ©2015 MindView LLC: see Copyright.txt package polymorphism.shape; import static com.mindviewinc.util.Print.*; @@ -8,4 +8,4 @@ public class Triangle extends Shape { public void draw() { print("Triangle.draw()"); } @Override public void erase() { print("Triangle.erase()"); } -} ///:~ +} diff --git a/references/AddingClone.java b/references/AddingClone.java index 74d60b46..df00d836 100644 --- a/references/AddingClone.java +++ b/references/AddingClone.java @@ -1,4 +1,4 @@ -//: references/AddingClone.java +// references/AddingClone.java // ©2015 MindView LLC: see Copyright.txt // You must go through a few gyrations // to add cloning to your own class. @@ -57,9 +57,10 @@ public class AddingClone { // See if it changed v's elements: System.out.println("v: " + v); } -} /* Output: +} +/* Output: x = 10, x2 = 11 v: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] v2: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] v: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] -*///:~ +*/ diff --git a/references/Alias1.java b/references/Alias1.java index 5a98f724..640c5f94 100644 --- a/references/Alias1.java +++ b/references/Alias1.java @@ -1,4 +1,4 @@ -//: references/Alias1.java +// references/Alias1.java // ©2015 MindView LLC: see Copyright.txt // Aliasing two references to one object. @@ -15,10 +15,11 @@ public class Alias1 { System.out.println("x: " + x.i); System.out.println("y: " + y.i); } -} /* Output: +} +/* Output: x: 7 y: 7 Incrementing x x: 8 y: 8 -*///:~ +*/ diff --git a/references/Alias2.java b/references/Alias2.java index fe2219fd..6938c6ae 100644 --- a/references/Alias2.java +++ b/references/Alias2.java @@ -1,4 +1,4 @@ -//: references/Alias2.java +// references/Alias2.java // ©2015 MindView LLC: see Copyright.txt // Method calls implicitly alias their arguments. @@ -13,8 +13,9 @@ public class Alias2 { f(x); System.out.println("x: " + x.i); } -} /* Output: +} +/* Output: x: 7 Calling f(x) x: 8 -*///:~ +*/ diff --git a/references/CheckCloneable.java b/references/CheckCloneable.java index 00d247da..6ddc61b8 100644 --- a/references/CheckCloneable.java +++ b/references/CheckCloneable.java @@ -1,4 +1,4 @@ -//: references/CheckCloneable.java +// references/CheckCloneable.java // ©2015 MindView LLC: see Copyright.txt // Check to see if a reference can be cloned. @@ -95,7 +95,8 @@ public class CheckCloneable { tryToClone(ord1); } } -} /* Output: +} +/* Output: Attempting IsCloneable Cloned IsCloneable Attempting WrongClone @@ -108,4 +109,4 @@ Attempting BackOn Cloned BackOn Attempting ReallyNoMore Could not clone ReallyNoMore -*///:~ +*/ diff --git a/references/Cloning.java b/references/Cloning.java index eb2ea16b..49190fc6 100644 --- a/references/Cloning.java +++ b/references/Cloning.java @@ -1,4 +1,4 @@ -//: references/Cloning.java +// references/Cloning.java // ©2015 MindView LLC: see Copyright.txt // The clone() operation works for only a few // items in the standard Java library. @@ -28,7 +28,8 @@ public class Cloning { // See if it changed v's elements: System.out.println("v: " + v); } -} /* Output: +} +/* Output: v: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] v: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -*///:~ +*/ diff --git a/references/Compete.java b/references/Compete.java index a1e77be4..cc95bcd2 100644 --- a/references/Compete.java +++ b/references/Compete.java @@ -1,4 +1,4 @@ -//: references/Compete.java +// references/Compete.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -76,7 +76,8 @@ public class Compete { "Duplication via cloning: " + (t2 - t1) + " Milliseconds"); } -} /* Output: +} +/* Output: Duplication via serialization: 274 Milliseconds Duplication via cloning: 21 Milliseconds -*///:~ +*/ diff --git a/references/CopyConstructor.java b/references/CopyConstructor.java index c6bc49e5..e4e1ec3a 100644 --- a/references/CopyConstructor.java +++ b/references/CopyConstructor.java @@ -1,4 +1,4 @@ -//: references/CopyConstructor.java +// references/CopyConstructor.java // ©2015 MindView LLC: see Copyright.txt // A constructor to copy an object of the same // type, as an attempt to create a local copy. @@ -171,7 +171,8 @@ public class CopyConstructor { slice2(g); // OK g.evaluate(); } -} /* Output: +} +/* Output: In ripen, t is a Tomato In slice, f is a Fruit In ripen2, t is a Tomato @@ -180,4 +181,4 @@ In ripen, t is a Tomato In slice, f is a Fruit In ripen2, t is a GreenZebra In slice2, f is a GreenZebra -*///:~ +*/ diff --git a/references/DeepCopy.java b/references/DeepCopy.java index a3ba4357..a148f3dd 100644 --- a/references/DeepCopy.java +++ b/references/DeepCopy.java @@ -1,4 +1,4 @@ -//: references/DeepCopy.java +// references/DeepCopy.java // ©2015 MindView LLC: see Copyright.txt // Cloning a composed object. // (Install libraries from www.junit.org) @@ -122,4 +122,5 @@ public class DeepCopy { org.junit.runner.JUnitCore.runClasses( DeepCopy.class); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/references/HorrorFlick.java b/references/HorrorFlick.java index 8d827da9..ad63995d 100644 --- a/references/HorrorFlick.java +++ b/references/HorrorFlick.java @@ -1,4 +1,4 @@ -//: references/HorrorFlick.java +// references/HorrorFlick.java // ©2015 MindView LLC: see Copyright.txt // You can insert Cloneability // at any level of inheritance. @@ -32,4 +32,5 @@ public class HorrorFlick { s = (Scientist)s.clone(); m = (MadScientist)m.clone(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/references/Immutable1.java b/references/Immutable1.java index ae0d5af0..e80e196c 100644 --- a/references/Immutable1.java +++ b/references/Immutable1.java @@ -1,4 +1,4 @@ -//: references/Immutable1.java +// references/Immutable1.java // ©2015 MindView LLC: see Copyright.txt // Immutable objects are immune to aliasing. @@ -23,9 +23,10 @@ public class Immutable1 { f(x); System.out.println("x = " + x.read()); } -} /* Output: +} +/* Output: x = 47 i1 = 47 quad = 188 x = 47 -*///:~ +*/ diff --git a/references/Immutable2.java b/references/Immutable2.java index f334beb4..7e375ebb 100644 --- a/references/Immutable2.java +++ b/references/Immutable2.java @@ -1,4 +1,4 @@ -//: references/Immutable2.java +// references/Immutable2.java // ©2015 MindView LLC: see Copyright.txt // A companion class to modify immutable objects @@ -61,8 +61,9 @@ public class Immutable2 { System.out.println("r1 = " + r1.read()); System.out.println("r2 = " + r2.read()); } -} /* Output: +} +/* Output: i2 = 47 r1 = 376 r2 = 376 -*///:~ +*/ diff --git a/references/ImmutableInteger.java b/references/ImmutableInteger.java index 74fc99d4..129d5f77 100644 --- a/references/ImmutableInteger.java +++ b/references/ImmutableInteger.java @@ -1,4 +1,4 @@ -//: references/ImmutableInteger.java +// references/ImmutableInteger.java // ©2015 MindView LLC: see Copyright.txt // The Integer class cannot be changed. import java.util.*; @@ -11,4 +11,5 @@ public class ImmutableInteger { // But how do you change the int // inside the Integer? } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/references/ImmutableStrings.java b/references/ImmutableStrings.java index d68ed9fd..ab2e00d6 100644 --- a/references/ImmutableStrings.java +++ b/references/ImmutableStrings.java @@ -1,4 +1,4 @@ -//: references/ImmutableStrings.java +// references/ImmutableStrings.java // ©2015 MindView LLC: see Copyright.txt // Demonstrating StringBuffer. @@ -16,7 +16,8 @@ public class ImmutableStrings { sb.append(Integer.toString(47)); System.out.println(sb); } -} /* Output: +} +/* Output: abcfoodef47 abcfoodef47 -*///:~ +*/ diff --git a/references/LocalCopy.java b/references/LocalCopy.java index 588b5a92..8a386c75 100644 --- a/references/LocalCopy.java +++ b/references/LocalCopy.java @@ -1,4 +1,4 @@ -//: references/LocalCopy.java +// references/LocalCopy.java // ©2015 MindView LLC: see Copyright.txt // Creating local copies with clone(). @@ -44,11 +44,12 @@ public class LocalCopy { System.out.println("c == d: " + (c == d) + "\nc = " + c + "\nd = " + d); } -} /* Output: +} +/* Output: a == b: true a = 12 b = 12 c == d: false c = 47 d = 48 -*///:~ +*/ diff --git a/references/MutableInteger.java b/references/MutableInteger.java index c429f621..eac9d5a5 100644 --- a/references/MutableInteger.java +++ b/references/MutableInteger.java @@ -1,4 +1,4 @@ -//: references/MutableInteger.java +// references/MutableInteger.java // ©2015 MindView LLC: see Copyright.txt // A changeable wrapper class. import java.util.*; @@ -25,7 +25,8 @@ public class MutableInteger { v.get(i).increment(); System.out.println(v); } -} /* Output: +} +/* Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -*///:~ +*/ diff --git a/references/PassReferences.java b/references/PassReferences.java index b8034a2f..c36d6a28 100644 --- a/references/PassReferences.java +++ b/references/PassReferences.java @@ -1,4 +1,4 @@ -//: references/PassReferences.java +// references/PassReferences.java // ©2015 MindView LLC: see Copyright.txt // Passing references around. @@ -11,7 +11,8 @@ public class PassReferences { System.out.println("p inside main(): " + p); f(p); } -} /* Output: +} +/* Output: p inside main(): PassReferences@19e0bfd h inside f(): PassReferences@19e0bfd -*///:~ +*/ diff --git a/references/Snake.java b/references/Snake.java index 79b69a8e..a33849d4 100644 --- a/references/Snake.java +++ b/references/Snake.java @@ -1,4 +1,4 @@ -//: references/Snake.java +// references/Snake.java // ©2015 MindView LLC: see Copyright.txt // Tests cloning to see if destination // of references are also cloned. @@ -43,8 +43,9 @@ public class Snake implements Cloneable { System.out.println( "after s.increment, s2 = " + s2); } -} /* Output: +} +/* Output: s = :a:b:c:d:e s2 = :a:b:c:d:e after s.increment, s2 = :a:c:d:e:f -*///:~ +*/ diff --git a/references/Stringer.java b/references/Stringer.java index b31e7885..afb327d1 100644 --- a/references/Stringer.java +++ b/references/Stringer.java @@ -1,4 +1,4 @@ -//: references/Stringer.java +// references/Stringer.java // ©2015 MindView LLC: see Copyright.txt public class Stringer { @@ -12,8 +12,9 @@ public class Stringer { System.out.println(qq); // HOWDY System.out.println(q); // howdy } -} /* Output: +} +/* Output: howdy HOWDY howdy -*///:~ +*/ diff --git a/remote/DisplayPerfectTime.java b/remote/DisplayPerfectTime.java index af2f5455..1c13c09c 100644 --- a/remote/DisplayPerfectTime.java +++ b/remote/DisplayPerfectTime.java @@ -1,4 +1,4 @@ -//: remote/DisplayPerfectTime.java +// remote/DisplayPerfectTime.java // ©2015 MindView LLC: see Copyright.txt // Uses remote object PerfectTime // {ValidateByHand} @@ -14,4 +14,4 @@ public class DisplayPerfectTime { for(int i = 0; i < 10; i++) System.out.println("Time: "+ pt.getPerfectTime()); } -} ///:~ +} diff --git a/remote/PerfectTime.java b/remote/PerfectTime.java index e68cab51..23c4ce70 100644 --- a/remote/PerfectTime.java +++ b/remote/PerfectTime.java @@ -1,8 +1,8 @@ -//: remote/PerfectTime.java +// remote/PerfectTime.java // ©2015 MindView LLC: see Copyright.txt // The PerfectTime remote interface import java.rmi.*; public interface PerfectTime extends Remote { long getPerfectTime() throws RemoteException; -} ///:~ +} diff --git a/remote/PerfectTimeImpl.java b/remote/PerfectTimeImpl.java index 63df223d..7906bd28 100644 --- a/remote/PerfectTimeImpl.java +++ b/remote/PerfectTimeImpl.java @@ -1,4 +1,4 @@ -//: remote/PerfectTimeImpl.java +// remote/PerfectTimeImpl.java // ©2015 MindView LLC: see Copyright.txt // The implementation of the PerfectTime // remote object. @@ -8,4 +8,4 @@ public class PerfectTimeImpl implements PerfectTime { public long getPerfectTime() throws RemoteException { return System.currentTimeMillis(); } -} ///:~ +} diff --git a/remote/PerfectTimeServer.java b/remote/PerfectTimeServer.java index 0ac19ea4..a0a610d1 100644 --- a/remote/PerfectTimeServer.java +++ b/remote/PerfectTimeServer.java @@ -1,4 +1,4 @@ -//: remote/PerfectTimeServer.java +// remote/PerfectTimeServer.java // ©2015 MindView LLC: see Copyright.txt // Server for the PerfectTime remote object. // {ValidateByHand} @@ -17,4 +17,4 @@ public class PerfectTimeServer { registry.rebind("PerfectTime", stub); System.out.println("Ready to do time"); } -} ///:~ +} diff --git a/reuse/Bath.java b/reuse/Bath.java index 7e0fa0fc..d2badd02 100644 --- a/reuse/Bath.java +++ b/reuse/Bath.java @@ -1,4 +1,4 @@ -//: reuse/Bath.java +// reuse/Bath.java // ©2015 MindView LLC: see Copyright.txt // Constructor initialization with composition. import static com.mindviewinc.util.Print.*; @@ -46,7 +46,8 @@ public class Bath { Bath b = new Bath(); print(b); } -} /* Output: +} +/* Output: Inside Bath() Soap() s1 = Happy @@ -56,4 +57,4 @@ s4 = Joy i = 47 toy = 3.14 castille = Constructed -*///:~ +*/ diff --git a/reuse/Beetle.java b/reuse/Beetle.java index c2f7ae1a..7099805c 100644 --- a/reuse/Beetle.java +++ b/reuse/Beetle.java @@ -1,4 +1,4 @@ -//: reuse/Beetle.java +// reuse/Beetle.java // ©2015 MindView LLC: see Copyright.txt // The full process of initialization. import static com.mindviewinc.util.Print.*; @@ -30,7 +30,8 @@ public class Beetle extends Insect { print("Beetle constructor"); Beetle b = new Beetle(); } -} /* Output: +} +/* Output: static Insect.x1 initialized static Beetle.x2 initialized Beetle constructor @@ -38,4 +39,4 @@ i = 9, j = 0 Beetle.k initialized k = 47 j = 39 -*///:~ +*/ diff --git a/reuse/BlankFinal.java b/reuse/BlankFinal.java index 6b905227..dbe4104d 100644 --- a/reuse/BlankFinal.java +++ b/reuse/BlankFinal.java @@ -1,4 +1,4 @@ -//: reuse/BlankFinal.java +// reuse/BlankFinal.java // ©2015 MindView LLC: see Copyright.txt // "Blank" final fields. @@ -24,4 +24,5 @@ public class BlankFinal { new BlankFinal(); new BlankFinal(47); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/reuse/CADSystem.java b/reuse/CADSystem.java index 69bbeb53..3c26a87b 100644 --- a/reuse/CADSystem.java +++ b/reuse/CADSystem.java @@ -1,4 +1,4 @@ -//: reuse/CADSystem.java +// reuse/CADSystem.java // ©2015 MindView LLC: see Copyright.txt // Ensuring proper cleanup. package reuse; @@ -79,7 +79,8 @@ public class CADSystem extends Shape { x.dispose(); } } -} /* Output: +} +/* Output: Shape constructor Shape constructor Drawing Line: 0, 0 @@ -104,4 +105,4 @@ Shape dispose Erasing Line: 0, 0 Shape dispose Shape dispose -*///:~ +*/ diff --git a/reuse/Car.java b/reuse/Car.java index adb77e86..a257cb52 100644 --- a/reuse/Car.java +++ b/reuse/Car.java @@ -1,4 +1,4 @@ -//: reuse/Car.java +// reuse/Car.java // ©2015 MindView LLC: see Copyright.txt // Composition with public objects. @@ -38,4 +38,5 @@ public class Car { car.left.window.rollup(); car.wheel[0].inflate(72); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/reuse/Cartoon.java b/reuse/Cartoon.java index dc2b67d3..d0e4891d 100644 --- a/reuse/Cartoon.java +++ b/reuse/Cartoon.java @@ -1,4 +1,4 @@ -//: reuse/Cartoon.java +// reuse/Cartoon.java // ©2015 MindView LLC: see Copyright.txt // Constructor calls during inheritance. import static com.mindviewinc.util.Print.*; @@ -16,8 +16,9 @@ public class Cartoon extends Drawing { public static void main(String[] args) { Cartoon x = new Cartoon(); } -} /* Output: +} +/* Output: Art constructor Drawing constructor Cartoon constructor -*///:~ +*/ diff --git a/reuse/Chess.java b/reuse/Chess.java index c8c10d20..4219e9cd 100644 --- a/reuse/Chess.java +++ b/reuse/Chess.java @@ -1,4 +1,4 @@ -//: reuse/Chess.java +// reuse/Chess.java // ©2015 MindView LLC: see Copyright.txt // Inheritance, constructors and arguments. import static com.mindviewinc.util.Print.*; @@ -24,8 +24,9 @@ public class Chess extends BoardGame { public static void main(String[] args) { Chess x = new Chess(); } -} /* Output: +} +/* Output: Game constructor BoardGame constructor Chess constructor -*///:~ +*/ diff --git a/reuse/Detergent.java b/reuse/Detergent.java index d6fcfe15..964d5cd4 100644 --- a/reuse/Detergent.java +++ b/reuse/Detergent.java @@ -1,4 +1,4 @@ -//: reuse/Detergent.java +// reuse/Detergent.java // ©2015 MindView LLC: see Copyright.txt // Inheritance syntax & properties. import static com.mindviewinc.util.Print.*; @@ -38,8 +38,9 @@ public class Detergent extends Cleanser { print("Testing base class:"); Cleanser.main(args); } -} /* Output: +} +/* Output: Cleanser dilute() apply() Detergent.scrub() scrub() foam() Testing base class: Cleanser dilute() apply() scrub() -*///:~ +*/ diff --git a/reuse/FinalArguments.java b/reuse/FinalArguments.java index 8f6591f0..84f28ddd 100644 --- a/reuse/FinalArguments.java +++ b/reuse/FinalArguments.java @@ -1,4 +1,4 @@ -//: reuse/FinalArguments.java +// reuse/FinalArguments.java // ©2015 MindView LLC: see Copyright.txt // Using "final" with method arguments. @@ -22,4 +22,5 @@ public class FinalArguments { bf.without(null); bf.with(null); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/reuse/FinalData.java b/reuse/FinalData.java index 715a024a..03526974 100644 --- a/reuse/FinalData.java +++ b/reuse/FinalData.java @@ -1,4 +1,4 @@ -//: reuse/FinalData.java +// reuse/FinalData.java // ©2015 MindView LLC: see Copyright.txt // The effect of final on fields. import java.util.*; @@ -46,9 +46,10 @@ public class FinalData { print(fd1); print(fd2); } -} /* Output: +} +/* Output: fd1: i4 = 15, INT_5 = 18 Creating new FinalData fd1: i4 = 15, INT_5 = 18 fd2: i4 = 13, INT_5 = 18 -*///:~ +*/ diff --git a/reuse/FinalOverridingIllusion.java b/reuse/FinalOverridingIllusion.java index f978a564..3b6a5ff7 100644 --- a/reuse/FinalOverridingIllusion.java +++ b/reuse/FinalOverridingIllusion.java @@ -1,4 +1,4 @@ -//: reuse/FinalOverridingIllusion.java +// reuse/FinalOverridingIllusion.java // ©2015 MindView LLC: see Copyright.txt // It only looks like you can override // a private or private final method. @@ -44,7 +44,8 @@ public class FinalOverridingIllusion { //! wf.f(); //! wf.g(); } -} /* Output: +} +/* Output: OverridingPrivate2.f() OverridingPrivate2.g() -*///:~ +*/ diff --git a/reuse/Hide.java b/reuse/Hide.java index 1fe87db8..f90882c6 100644 --- a/reuse/Hide.java +++ b/reuse/Hide.java @@ -1,4 +1,4 @@ -//: reuse/Hide.java +// reuse/Hide.java // ©2015 MindView LLC: see Copyright.txt // Overloading a base-class method name in a derived // class does not hide the base-class versions. @@ -31,9 +31,10 @@ public class Hide { b.doh(1.0f); b.doh(new Milhouse()); } -} /* Output: +} +/* Output: doh(float) doh(char) doh(float) doh(Milhouse) -*///:~ +*/ diff --git a/reuse/Jurassic.java b/reuse/Jurassic.java index 91593ffe..82ed57b3 100644 --- a/reuse/Jurassic.java +++ b/reuse/Jurassic.java @@ -1,4 +1,4 @@ -//: reuse/Jurassic.java +// reuse/Jurassic.java // ©2015 MindView LLC: see Copyright.txt // Making an entire class final. @@ -21,4 +21,5 @@ public class Jurassic { n.i = 40; n.j++; } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/reuse/Lisa.java b/reuse/Lisa.java index 765e86a6..934ce7cb 100644 --- a/reuse/Lisa.java +++ b/reuse/Lisa.java @@ -1,4 +1,4 @@ -//: reuse/Lisa.java +// reuse/Lisa.java // ©2015 MindView LLC: see Copyright.txt // {CompileTimeError} (Won't compile) @@ -6,4 +6,4 @@ class Lisa extends Homer { @Override void doh(Milhouse m) { System.out.println("doh(Milhouse)"); } -} ///:~ +} diff --git a/reuse/Orc.java b/reuse/Orc.java index 0ddc52b4..9ddf995a 100644 --- a/reuse/Orc.java +++ b/reuse/Orc.java @@ -1,4 +1,4 @@ -//: reuse/Orc.java +// reuse/Orc.java // ©2015 MindView LLC: see Copyright.txt // The protected keyword. import static com.mindviewinc.util.Print.*; @@ -33,7 +33,8 @@ public class Orc extends Villain { orc.change("Bob", 19); print(orc); } -} /* Output: +} +/* Output: Orc 12: I'm a Villain and my name is Limburger Orc 19: I'm a Villain and my name is Bob -*///:~ +*/ diff --git a/reuse/PlaceSetting.java b/reuse/PlaceSetting.java index f10405d9..63db7e5f 100644 --- a/reuse/PlaceSetting.java +++ b/reuse/PlaceSetting.java @@ -1,4 +1,4 @@ -//: reuse/PlaceSetting.java +// reuse/PlaceSetting.java // ©2015 MindView LLC: see Copyright.txt // Combining composition & inheritance. import static com.mindviewinc.util.Print.*; @@ -66,7 +66,8 @@ public class PlaceSetting extends Custom { public static void main(String[] args) { PlaceSetting x = new PlaceSetting(9); } -} /* Output: +} +/* Output: Custom constructor Utensil constructor Spoon constructor @@ -77,4 +78,4 @@ Knife constructor Plate constructor DinnerPlate constructor PlaceSetting constructor -*///:~ +*/ diff --git a/reuse/SpaceShip.java b/reuse/SpaceShip.java index a554a908..9ff42cea 100644 --- a/reuse/SpaceShip.java +++ b/reuse/SpaceShip.java @@ -1,4 +1,4 @@ -//: reuse/SpaceShip.java +// reuse/SpaceShip.java // ©2015 MindView LLC: see Copyright.txt public class SpaceShip extends SpaceShipControls { @@ -10,4 +10,5 @@ public class SpaceShip extends SpaceShipControls { SpaceShip protector = new SpaceShip("NSEA Protector"); protector.forward(100); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/reuse/SpaceShipControls.java b/reuse/SpaceShipControls.java index 11beb429..d6284e3b 100644 --- a/reuse/SpaceShipControls.java +++ b/reuse/SpaceShipControls.java @@ -1,4 +1,4 @@ -//: reuse/SpaceShipControls.java +// reuse/SpaceShipControls.java // ©2015 MindView LLC: see Copyright.txt public class SpaceShipControls { @@ -9,4 +9,4 @@ public class SpaceShipControls { void forward(int velocity) {} void back(int velocity) {} void turboBoost() {} -} ///:~ +} diff --git a/reuse/SpaceShipDelegation.java b/reuse/SpaceShipDelegation.java index 50d2d967..d9fdb054 100644 --- a/reuse/SpaceShipDelegation.java +++ b/reuse/SpaceShipDelegation.java @@ -1,4 +1,4 @@ -//: reuse/SpaceShipDelegation.java +// reuse/SpaceShipDelegation.java // ©2015 MindView LLC: see Copyright.txt public class SpaceShipDelegation { @@ -35,4 +35,5 @@ public class SpaceShipDelegation { new SpaceShipDelegation("NSEA Protector"); protector.forward(100); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/reuse/SprinklerSystem.java b/reuse/SprinklerSystem.java index ce249800..fda4a31c 100644 --- a/reuse/SprinklerSystem.java +++ b/reuse/SprinklerSystem.java @@ -1,4 +1,4 @@ -//: reuse/SprinklerSystem.java +// reuse/SprinklerSystem.java // ©2015 MindView LLC: see Copyright.txt // Composition for code reuse. @@ -31,8 +31,9 @@ public class SprinklerSystem { SprinklerSystem sprinklers = new SprinklerSystem(); System.out.println(sprinklers); } -} /* Output: +} +/* Output: WaterSource() valve1 = null valve2 = null valve3 = null valve4 = null i = 0 f = 0.0 source = Constructed -*///:~ +*/ diff --git a/reuse/Wind.java b/reuse/Wind.java index a51c4fa2..cf5cf27a 100644 --- a/reuse/Wind.java +++ b/reuse/Wind.java @@ -1,4 +1,4 @@ -//: reuse/Wind.java +// reuse/Wind.java // ©2015 MindView LLC: see Copyright.txt // Inheritance & upcasting. @@ -17,4 +17,5 @@ public class Wind extends Instrument { Wind flute = new Wind(); Instrument.tune(flute); // Upcasting } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/run.bat b/run.bat index a3ab3884..83d7120c 100644 --- a/run.bat +++ b/run.bat @@ -1,3 +1,3 @@ -python ..\Validate.py -p +python ..\tools\Validate.py -p powershell .\runall.ps1 -python ..\Validate.py -e +python ..\tools\Validate.py -e diff --git a/staticchecking/DogsAndRobots.cpp b/staticchecking/DogsAndRobots.cpp index 361c0ea5..46df3892 100644 --- a/staticchecking/DogsAndRobots.cpp +++ b/staticchecking/DogsAndRobots.cpp @@ -1,4 +1,4 @@ -//: staticchecking/DogsAndRobots.cpp +// staticchecking/DogsAndRobots.cpp // ©2015 MindView LLC: see Copyright.txt #include using namespace std; @@ -24,4 +24,4 @@ int main() { Robot r; speak(d); speak(r); -} ///:~ +} diff --git a/staticchecking/DogsAndRobots.py b/staticchecking/DogsAndRobots.py index 84914155..6835643a 100644 --- a/staticchecking/DogsAndRobots.py +++ b/staticchecking/DogsAndRobots.py @@ -1,4 +1,4 @@ -#: staticchecking/DogsAndRobots.py +# staticchecking/DogsAndRobots.py # ©2015 MindView LLC: see Copyright.txt def speak(anything): @@ -17,4 +17,4 @@ b = Robot() speak(a) speak(b) -#:~ +#> diff --git a/staticchecking/NoBasePetSpeak.py b/staticchecking/NoBasePetSpeak.py index e3f922da..ad014b1c 100644 --- a/staticchecking/NoBasePetSpeak.py +++ b/staticchecking/NoBasePetSpeak.py @@ -1,4 +1,4 @@ -#: staticchecking/NoBasePetSpeak.py +# staticchecking/NoBasePetSpeak.py # ©2015 MindView LLC: see Copyright.txt # Speaking pets without base classes: @@ -25,4 +25,4 @@ pets = [ Cat(), Dog(), Bob() ] for pet in pets: command(pet) -#:~ +#> diff --git a/staticchecking/PetSpeak.py b/staticchecking/PetSpeak.py index cd40163c..4c0f5a7e 100644 --- a/staticchecking/PetSpeak.py +++ b/staticchecking/PetSpeak.py @@ -1,4 +1,4 @@ -#: staticchecking/PetSpeak.py +# staticchecking/PetSpeak.py # ©2015 MindView LLC: see Copyright.txt # Speaking pets in Python @@ -19,4 +19,4 @@ def command(pet): pets = [ Cat(), Dog() ] for pet in pets: command(pet) -#:~ +#> diff --git a/staticchecking/dr/DogsAndRobots.java b/staticchecking/dr/DogsAndRobots.java index c54f4243..31d974e0 100644 --- a/staticchecking/dr/DogsAndRobots.java +++ b/staticchecking/dr/DogsAndRobots.java @@ -1,4 +1,4 @@ -//: staticchecking/dr/DogsAndRobots.java +// staticchecking/dr/DogsAndRobots.java // ©2015 MindView LLC: see Copyright.txt package staticchecking.dr; @@ -32,7 +32,8 @@ public class DogsAndRobots { Communicate.speak(d); Communicate.speak(r); } -} /* Output: +} +/* Output: Woof! Click! -*///:~ +*/ diff --git a/staticchecking/drc/DogAndRobotCollections.java b/staticchecking/drc/DogAndRobotCollections.java index ea638a0d..3ffc3ee6 100644 --- a/staticchecking/drc/DogAndRobotCollections.java +++ b/staticchecking/drc/DogAndRobotCollections.java @@ -1,4 +1,4 @@ -//: staticchecking/drc/DogAndRobotCollections.java +// staticchecking/drc/DogAndRobotCollections.java // ©2015 MindView LLC: see Copyright.txt package staticchecking.drc; import java.util.*; @@ -32,7 +32,8 @@ public class DogAndRobotCollections { // No cast necessary robotList.forEach(Robot::talk); } -} /* Output: +} +/* Output: Woof! Woof! Woof! @@ -53,4 +54,4 @@ Click! Click! Click! Click! -*///:~ +*/ diff --git a/staticchecking/latent/Latent.java b/staticchecking/latent/Latent.java index 6aec36dc..699326c0 100644 --- a/staticchecking/latent/Latent.java +++ b/staticchecking/latent/Latent.java @@ -1,4 +1,4 @@ -//: staticchecking/latent/Latent.java +// staticchecking/latent/Latent.java // ©2015 MindView LLC: see Copyright.txt package staticchecking.latent; import java.lang.reflect.*; @@ -49,8 +49,9 @@ public class Latent { Communicate.speak(new Robot()); Communicate.speak(new Mime()); } -} /* Output: +} +/* Output: Woof! Click! Mime cannot talk -*///:~ +*/ diff --git a/staticchecking/petspeak/PetSpeak.java b/staticchecking/petspeak/PetSpeak.java index 8649c686..07bae241 100644 --- a/staticchecking/petspeak/PetSpeak.java +++ b/staticchecking/petspeak/PetSpeak.java @@ -1,4 +1,4 @@ -//: staticchecking/petspeak/PetSpeak.java +// staticchecking/petspeak/PetSpeak.java // ©2015 MindView LLC: see Copyright.txt // Speaking pets in Java package staticchecking.petspeak; @@ -26,7 +26,8 @@ public class PetSpeak { for(Pet pet : pets) command(pet); } -} /* Output: +} +/* Output: meow! woof! -*///:~ +*/ diff --git a/strings/ArrayListDisplay.java b/strings/ArrayListDisplay.java index b392d620..8902cc69 100644 --- a/strings/ArrayListDisplay.java +++ b/strings/ArrayListDisplay.java @@ -1,4 +1,4 @@ -//: strings/ArrayListDisplay.java +// strings/ArrayListDisplay.java // ©2015 MindView LLC: see Copyright.txt import generics.coffee.*; import java.util.*; @@ -10,7 +10,8 @@ public class ArrayListDisplay { coffees.add(c); System.out.println(coffees); } -} /* Output: +} +/* Output: [Americano 0, Latte 1, Americano 2, Mocha 3, Mocha 4, Breve 5, Americano 6, Latte 7, Cappuccino 8, Cappuccino 9] -*///:~ +*/ diff --git a/strings/BetterRead.java b/strings/BetterRead.java index 5bb85d12..890f2aba 100644 --- a/strings/BetterRead.java +++ b/strings/BetterRead.java @@ -1,4 +1,4 @@ -//: strings/BetterRead.java +// strings/BetterRead.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -21,7 +21,8 @@ public class BetterRead { System.out.format("My favorite double is %f.", favorite / 2); } -} /* Output: +} +/* Output: What is your name? Sir Robin of Camelot How old are you? What is your favorite double? @@ -31,4 +32,4 @@ How old are you? What is your favorite double? Hi Sir Robin of Camelot. In 5 years you will be 27. My favorite double is 0.809015. -*///:~ +*/ diff --git a/strings/Concatenation.java b/strings/Concatenation.java index 7c1de29e..e25974b2 100644 --- a/strings/Concatenation.java +++ b/strings/Concatenation.java @@ -1,4 +1,4 @@ -//: strings/Concatenation.java +// strings/Concatenation.java // ©2015 MindView LLC: see Copyright.txt public class Concatenation { @@ -7,6 +7,7 @@ public class Concatenation { String s = "abc" + mango + "def" + 47; System.out.println(s); } -} /* Output: +} +/* Output: abcmangodef47 -*///:~ +*/ diff --git a/strings/Conversion.java b/strings/Conversion.java index fe569b9e..641a854c 100644 --- a/strings/Conversion.java +++ b/strings/Conversion.java @@ -1,4 +1,4 @@ -//: strings/Conversion.java +// strings/Conversion.java // ©2015 MindView LLC: see Copyright.txt import java.math.*; import java.util.*; @@ -74,7 +74,8 @@ public class Conversion { // f.format("x: %x\n", z); f.format("h: %h\n", z); } -} /* Output: +} +/* Output: u = 'a' s: a c: a @@ -107,4 +108,4 @@ z = false b: false s: false h: 4d5 -*///:~ +*/ diff --git a/strings/DatabaseException.java b/strings/DatabaseException.java index 5f1e35bf..c0ed2439 100644 --- a/strings/DatabaseException.java +++ b/strings/DatabaseException.java @@ -1,4 +1,4 @@ -//: strings/DatabaseException.java +// strings/DatabaseException.java // ©2015 MindView LLC: see Copyright.txt public class DatabaseException extends Exception { @@ -14,6 +14,7 @@ public class DatabaseException extends Exception { System.out.println(e); } } -} /* Output: +} +/* Output: DatabaseException: (t3, q7) Write failed -*///:~ +*/ diff --git a/strings/Finding.java b/strings/Finding.java index e36e4ca0..2cc004bf 100644 --- a/strings/Finding.java +++ b/strings/Finding.java @@ -1,4 +1,4 @@ -//: strings/Finding.java +// strings/Finding.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; import static com.mindviewinc.util.Print.*; @@ -16,9 +16,10 @@ public class Finding { i++; } } -} /* Output: +} +/* Output: Evening is full of the linnet s wings Evening vening ening ning ing ng g is is s full full ull ll l of of f the the he e linnet linnet innet nnet net et t s s wings wings ings ngs gs s -*///:~ +*/ diff --git a/strings/Groups.java b/strings/Groups.java index 7f9264fa..58e98f12 100644 --- a/strings/Groups.java +++ b/strings/Groups.java @@ -1,4 +1,4 @@ -//: strings/Groups.java +// strings/Groups.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; import static com.mindviewinc.util.Print.*; @@ -23,7 +23,8 @@ public class Groups { print(); } } -} /* Output: +} +/* Output: [the slithy toves][the][slithy toves][slithy][toves] [in the wabe.][in][the wabe.][the][wabe.] [were the borogoves,][were][the @@ -35,4 +36,4 @@ outgrabe.][raths][outgrabe.] [bird, and shun][bird,][and shun][and][shun] [The frumious Bandersnatch.][The][frumious Bandersnatch.][frumious][Bandersnatch.] -*///:~ +*/ diff --git a/strings/Immutable.java b/strings/Immutable.java index 64cfaa3e..e05ab989 100644 --- a/strings/Immutable.java +++ b/strings/Immutable.java @@ -1,4 +1,4 @@ -//: strings/Immutable.java +// strings/Immutable.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -13,8 +13,9 @@ public class Immutable { print(qq); // HOWDY print(q); // howdy } -} /* Output: +} +/* Output: howdy HOWDY howdy -*///:~ +*/ diff --git a/strings/InfiniteRecursion.java b/strings/InfiniteRecursion.java index ec00e615..9007169c 100644 --- a/strings/InfiniteRecursion.java +++ b/strings/InfiniteRecursion.java @@ -1,4 +1,4 @@ -//: strings/InfiniteRecursion.java +// strings/InfiniteRecursion.java // ©2015 MindView LLC: see Copyright.txt // Accidental recursion. // {ThrowsException} @@ -16,4 +16,4 @@ public class InfiniteRecursion { v.add(new InfiniteRecursion()); System.out.println(v); } -} ///:~ +} diff --git a/strings/IntegerMatch.java b/strings/IntegerMatch.java index 3d6d2dc3..4996e386 100644 --- a/strings/IntegerMatch.java +++ b/strings/IntegerMatch.java @@ -1,4 +1,4 @@ -//: strings/IntegerMatch.java +// strings/IntegerMatch.java // ©2015 MindView LLC: see Copyright.txt public class IntegerMatch { @@ -8,9 +8,10 @@ public class IntegerMatch { System.out.println("+911".matches("-?\\d+")); System.out.println("+911".matches("(-|\\+)?\\d+")); } -} /* Output: +} +/* Output: true true false true -*///:~ +*/ diff --git a/strings/JGrep.java b/strings/JGrep.java index 4f813bbf..ef6da3ec 100644 --- a/strings/JGrep.java +++ b/strings/JGrep.java @@ -1,4 +1,4 @@ -//: strings/JGrep.java +// strings/JGrep.java // ©2015 MindView LLC: see Copyright.txt // A very simple version of the "grep" program. // {Args: JGrep.java 'void|int|String'} @@ -22,7 +22,8 @@ public class JGrep { m.group() + ": " + m.start()); } } -} /* Output: +} +/* Output: 0: 'void: 21 1: int: 27 2: String': 31 @@ -47,4 +48,4 @@ public class JGrep { 21: int: 4 22: int: 4 23: int: 4 -*///:~ +*/ diff --git a/strings/ReFlags.java b/strings/ReFlags.java index d355d663..981ca671 100644 --- a/strings/ReFlags.java +++ b/strings/ReFlags.java @@ -1,4 +1,4 @@ -//: strings/ReFlags.java +// strings/ReFlags.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; @@ -13,8 +13,9 @@ public class ReFlags { while(m.find()) System.out.println(m.group()); } -} /* Output: +} +/* Output: java Java JAVA -*///:~ +*/ diff --git a/strings/Receipt.java b/strings/Receipt.java index e3bb6346..ec9bebf6 100644 --- a/strings/Receipt.java +++ b/strings/Receipt.java @@ -1,4 +1,4 @@ -//: strings/Receipt.java +// strings/Receipt.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -27,7 +27,8 @@ public class Receipt { receipt.print("Three Bears Porridge", 1, 14.29); receipt.printTotal(); } -} /* Output: +} +/* Output: Item Qty Price ---- --- ----- Jack's Magic Be 4 4.25 @@ -36,4 +37,4 @@ Three Bears Por 1 14.29 Tax 2.80 ----- Total 49.39 -*///:~ +*/ diff --git a/strings/Replacing.java b/strings/Replacing.java index acc6615e..6ddea43d 100644 --- a/strings/Replacing.java +++ b/strings/Replacing.java @@ -1,4 +1,4 @@ -//: strings/Replacing.java +// strings/Replacing.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -8,9 +8,10 @@ public class Replacing { print(s.replaceFirst("f\\w+", "located")); print(s.replaceAll("shrubbery|tree|herring","banana")); } -} /* Output: +} +/* Output: Then, when you have located the shrubbery, you must cut down the mightiest tree in the forest... with... a herring! Then, when you have found the banana, you must cut down the mightiest banana in the forest... with... a banana! -*///:~ +*/ diff --git a/strings/ReplacingStringTokenizer.java b/strings/ReplacingStringTokenizer.java index 82d6bb4d..c68565f4 100644 --- a/strings/ReplacingStringTokenizer.java +++ b/strings/ReplacingStringTokenizer.java @@ -1,4 +1,4 @@ -//: strings/ReplacingStringTokenizer.java +// strings/ReplacingStringTokenizer.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -14,8 +14,9 @@ public class ReplacingStringTokenizer { while(scanner.hasNext()) System.out.print(scanner.next() + " "); } -} /* Output: +} +/* Output: But I'm not dead yet! I feel happy! [But, I'm, not, dead, yet!, I, feel, happy!] But I'm not dead yet! I feel happy! -*///:~ +*/ diff --git a/strings/Resetting.java b/strings/Resetting.java index 186c5541..71ed6cdc 100644 --- a/strings/Resetting.java +++ b/strings/Resetting.java @@ -1,4 +1,4 @@ -//: strings/Resetting.java +// strings/Resetting.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; @@ -13,7 +13,8 @@ public class Resetting { while(m.find()) System.out.print(m.group() + " "); } -} /* Output: +} +/* Output: fix rug bag fix rig rag -*///:~ +*/ diff --git a/strings/Rudolph.java b/strings/Rudolph.java index 07d466e5..5013ba00 100644 --- a/strings/Rudolph.java +++ b/strings/Rudolph.java @@ -1,4 +1,4 @@ -//: strings/Rudolph.java +// strings/Rudolph.java // ©2015 MindView LLC: see Copyright.txt public class Rudolph { @@ -7,9 +7,10 @@ public class Rudolph { "[rR]udolph", "[rR][aeiou][a-z]ol.*", "R.*" }) System.out.println("Rudolph".matches(pattern)); } -} /* Output: +} +/* Output: true true true true -*///:~ +*/ diff --git a/strings/ScannerDelimiter.java b/strings/ScannerDelimiter.java index e16dd054..fda74279 100644 --- a/strings/ScannerDelimiter.java +++ b/strings/ScannerDelimiter.java @@ -1,4 +1,4 @@ -//: strings/ScannerDelimiter.java +// strings/ScannerDelimiter.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -9,10 +9,11 @@ public class ScannerDelimiter { while(scanner.hasNextInt()) System.out.println(scanner.nextInt()); } -} /* Output: +} +/* Output: 12 42 78 99 42 -*///:~ +*/ diff --git a/strings/SimpleFormat.java b/strings/SimpleFormat.java index 335bf7f8..febeceab 100644 --- a/strings/SimpleFormat.java +++ b/strings/SimpleFormat.java @@ -1,4 +1,4 @@ -//: strings/SimpleFormat.java +// strings/SimpleFormat.java // ©2015 MindView LLC: see Copyright.txt public class SimpleFormat { @@ -12,8 +12,9 @@ public class SimpleFormat { // or System.out.printf("Row 1: [%d %f]\n", x, y); } -} /* Output: +} +/* Output: Row 1: [5 5.332542] Row 1: [5 5.332542] Row 1: [5 5.332542] -*///:~ +*/ diff --git a/strings/SimpleRead.java b/strings/SimpleRead.java index cb59e87f..ea876847 100644 --- a/strings/SimpleRead.java +++ b/strings/SimpleRead.java @@ -1,4 +1,4 @@ -//: strings/SimpleRead.java +// strings/SimpleRead.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; @@ -27,7 +27,8 @@ public class SimpleRead { System.err.println("I/O exception"); } } -} /* Output: +} +/* Output: What is your name? Sir Robin of Camelot How old are you? What is your favorite double? @@ -36,4 +37,4 @@ How old are you? What is your favorite double? Hi Sir Robin of Camelot. In 5 years you will be 27. My favorite double is 0.809015. -*///:~ +*/ diff --git a/strings/SplitDemo.java b/strings/SplitDemo.java index 5725effb..a27c17dc 100644 --- a/strings/SplitDemo.java +++ b/strings/SplitDemo.java @@ -1,4 +1,4 @@ -//: strings/SplitDemo.java +// strings/SplitDemo.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; import java.util.*; @@ -14,7 +14,8 @@ public class SplitDemo { print(Arrays.toString( Pattern.compile("!!").split(input, 3))); } -} /* Output: +} +/* Output: [This, unusual use, of exclamation, points] [This, unusual use, of exclamation!!points] -*///:~ +*/ diff --git a/strings/Splitting.java b/strings/Splitting.java index 4f93f0f3..2664b29b 100644 --- a/strings/Splitting.java +++ b/strings/Splitting.java @@ -1,4 +1,4 @@ -//: strings/Splitting.java +// strings/Splitting.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -16,7 +16,8 @@ public class Splitting { split("\\W+"); // Non-word characters split("n\\W+"); // 'n' followed by non-word characters } -} /* Output: +} +/* Output: [Then,, when, you, have, found, the, shrubbery,, you, must, cut, down, the, mightiest, tree, in, the, forest..., with..., a, herring!] @@ -25,4 +26,4 @@ cut, down, the, mightiest, tree, in, the, forest, with, a, herring] [The, whe, you have found the shrubbery, you must cut dow, the mightiest tree i, the forest... with... a herring!] -*///:~ +*/ diff --git a/strings/StartEnd.java b/strings/StartEnd.java index 2b173fae..9c6b0965 100644 --- a/strings/StartEnd.java +++ b/strings/StartEnd.java @@ -1,4 +1,4 @@ -//: strings/StartEnd.java +// strings/StartEnd.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; import static com.mindviewinc.util.Print.*; @@ -44,7 +44,8 @@ public class StartEnd { examine(in, regex); } } -} /* Output: +} +/* Output: input : As long as there is injustice, whenever a \w*ere\w* find() 'there' start = 11 end = 16 @@ -75,4 +76,4 @@ find() 'Never give up!' start = 0 end = 14 find() 'Never surrender!' start = 15 end = 31 lookingAt() start = 0 end = 14 matches() start = 0 end = 31 -*///:~ +*/ diff --git a/strings/TestRegularExpression.java b/strings/TestRegularExpression.java index 957f6753..6b34e4fd 100644 --- a/strings/TestRegularExpression.java +++ b/strings/TestRegularExpression.java @@ -1,4 +1,4 @@ -//: strings/TestRegularExpression.java +// strings/TestRegularExpression.java // ©2015 MindView LLC: see Copyright.txt // Easily try out regular expressions. // {Args: abcabcabcdefabc "abc+" "(abc)+" "(abc){2,}" } @@ -23,7 +23,8 @@ public class TestRegularExpression { } } } -} /* Output: +} +/* Output: Input: "abcabcabcdefabc" Regular expression: "abcabcabcdefabc" Match "abcabcabcdefabc" at positions 0-14 @@ -37,4 +38,4 @@ Match "abcabcabc" at positions 0-8 Match "abc" at positions 12-14 Regular expression: "(abc){2,}" Match "abcabcabc" at positions 0-8 -*///:~ +*/ diff --git a/strings/TheReplacements.java b/strings/TheReplacements.java index 46c672e1..6529d597 100644 --- a/strings/TheReplacements.java +++ b/strings/TheReplacements.java @@ -1,4 +1,4 @@ -//: strings/TheReplacements.java +// strings/TheReplacements.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; import com.mindviewinc.util.*; @@ -37,7 +37,8 @@ public class TheReplacements { m.appendTail(sbuf); print(sbuf); } -} /* Output: +} +/* Output: Here's a block of text to use as input to the regular expression matcher. Note that we first extract the block of text by looking for @@ -48,4 +49,4 @@ thE rEgUlAr ExprEssIOn mAtchEr. NOtE thAt wE fIrst ExtrAct thE blOck Of tExt by lOOkIng fOr thE spEcIAl dElImItErs, thEn prOcEss thE ExtrActEd blOck. -*///:~ +*/ diff --git a/strings/ThreatAnalyzer.java b/strings/ThreatAnalyzer.java index 819deab1..de2721e4 100644 --- a/strings/ThreatAnalyzer.java +++ b/strings/ThreatAnalyzer.java @@ -1,4 +1,4 @@ -//: strings/ThreatAnalyzer.java +// strings/ThreatAnalyzer.java // ©2015 MindView LLC: see Copyright.txt import java.util.regex.*; import java.util.*; @@ -23,10 +23,11 @@ public class ThreatAnalyzer { System.out.format("Threat on %s from %s\n", date,ip); } } -} /* Output: +} +/* Output: Threat on 02/10/2005 from 58.27.82.161 Threat on 02/11/2005 from 204.45.234.40 Threat on 02/11/2005 from 58.27.82.161 Threat on 02/12/2005 from 58.27.82.161 Threat on 02/12/2005 from 58.27.82.161 -*///:~ +*/ diff --git a/strings/Turtle.java b/strings/Turtle.java index 774e4830..9c47fffd 100644 --- a/strings/Turtle.java +++ b/strings/Turtle.java @@ -1,4 +1,4 @@ -//: strings/Turtle.java +// strings/Turtle.java // ©2015 MindView LLC: see Copyright.txt import java.io.*; import java.util.*; @@ -26,11 +26,12 @@ public class Turtle { tommy.move(3,3); terry.move(3,3); } -} /* Output: +} +/* Output: Tommy The Turtle is at (0,0) Terry The Turtle is at (4,8) Tommy The Turtle is at (3,4) Terry The Turtle is at (2,5) Tommy The Turtle is at (3,3) Terry The Turtle is at (3,3) -*///:~ +*/ diff --git a/strings/UsingStringBuilder.java b/strings/UsingStringBuilder.java index 1a54c220..639947c8 100644 --- a/strings/UsingStringBuilder.java +++ b/strings/UsingStringBuilder.java @@ -1,4 +1,4 @@ -//: strings/UsingStringBuilder.java +// strings/UsingStringBuilder.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -19,7 +19,8 @@ public class UsingStringBuilder { UsingStringBuilder usb = new UsingStringBuilder(); System.out.println(usb); } -} /* Output: +} +/* Output: [58, 55, 93, 61, 61, 29, 68, 0, 22, 7, 88, 28, 51, 89, 9, 78, 98, 61, 20, 58, 16, 40, 11, 22, 4] -*///:~ +*/ diff --git a/strings/WhitherStringBuilder.java b/strings/WhitherStringBuilder.java index 3d6a1e12..8861d7ec 100644 --- a/strings/WhitherStringBuilder.java +++ b/strings/WhitherStringBuilder.java @@ -1,4 +1,4 @@ -//: strings/WhitherStringBuilder.java +// strings/WhitherStringBuilder.java // ©2015 MindView LLC: see Copyright.txt public class WhitherStringBuilder { @@ -16,4 +16,4 @@ public class WhitherStringBuilder { } return result.toString(); } -} ///:~ +} diff --git a/swt/ColorBoxes.java b/swt/ColorBoxes.java index e571ec28..c415b4c0 100644 --- a/swt/ColorBoxes.java +++ b/swt/ColorBoxes.java @@ -1,4 +1,4 @@ -//: swt/ColorBoxes.java +// swt/ColorBoxes.java // ©2015 MindView LLC: see Copyright.txt // SWT translation of Swing ColorBoxes.java. import swt.util.*; @@ -78,4 +78,4 @@ public class ColorBoxes implements SWTApplication { boxes.pause = new Integer(args[1]); SWTConsole.run(boxes, 500, 400); } -} ///:~ +} diff --git a/swt/DisplayEnvironment.java b/swt/DisplayEnvironment.java index e8720b00..9757467d 100644 --- a/swt/DisplayEnvironment.java +++ b/swt/DisplayEnvironment.java @@ -1,4 +1,4 @@ -//: swt/DisplayEnvironment.java +// swt/DisplayEnvironment.java // ©2015 MindView LLC: see Copyright.txt import swt.util.*; import org.eclipse.swt.*; @@ -19,4 +19,4 @@ public class DisplayEnvironment implements SWTApplication { public static void main(String [] args) { SWTConsole.run(new DisplayEnvironment(), 800, 600); } -} ///:~ +} diff --git a/swt/DisplayProperties.java b/swt/DisplayProperties.java index ebb7a9a1..c2b8ad52 100644 --- a/swt/DisplayProperties.java +++ b/swt/DisplayProperties.java @@ -1,4 +1,4 @@ -//: swt/DisplayProperties.java +// swt/DisplayProperties.java // ©2015 MindView LLC: see Copyright.txt import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; @@ -21,4 +21,4 @@ public class DisplayProperties { display.sleep(); display.dispose(); } -} ///:~ +} diff --git a/swt/HelloSWT.java b/swt/HelloSWT.java index 5dab3123..abdad85a 100644 --- a/swt/HelloSWT.java +++ b/swt/HelloSWT.java @@ -1,4 +1,4 @@ -//: swt/HelloSWT.java +// swt/HelloSWT.java // ©2015 MindView LLC: see Copyright.txt // {Requires: org.eclipse.swt.widgets.Display; You must // install the SWT library from http://www.eclipse.org } @@ -15,4 +15,4 @@ public class HelloSWT { display.sleep(); display.dispose(); } -} ///:~ +} diff --git a/swt/Menus.java b/swt/Menus.java index 972fc0d3..0f3f78f9 100644 --- a/swt/Menus.java +++ b/swt/Menus.java @@ -1,4 +1,4 @@ -//: swt/Menus.java +// swt/Menus.java // ©2015 MindView LLC: see Copyright.txt // Fun with menus. import swt.util.*; @@ -46,4 +46,4 @@ public class Menus implements SWTApplication { public static void main(String[] args) { SWTConsole.run(new Menus(), 600, 200); } -} ///:~ +} diff --git a/swt/ShellsAreMainWindows.java b/swt/ShellsAreMainWindows.java index 14e9f1f2..19f7f3b2 100644 --- a/swt/ShellsAreMainWindows.java +++ b/swt/ShellsAreMainWindows.java @@ -1,4 +1,4 @@ -//: swt/ShellsAreMainWindows.java +// swt/ShellsAreMainWindows.java // ©2015 MindView LLC: see Copyright.txt import org.eclipse.swt.widgets.*; @@ -24,4 +24,4 @@ public class ShellsAreMainWindows { } return false; } -} ///:~ +} diff --git a/swt/SineWave.java b/swt/SineWave.java index 2f7cba7a..e1f8b58c 100644 --- a/swt/SineWave.java +++ b/swt/SineWave.java @@ -1,4 +1,4 @@ -//: swt/SineWave.java +// swt/SineWave.java // ©2015 MindView LLC: see Copyright.txt // SWT translation of Swing SineWave.java. import swt.util.*; @@ -72,4 +72,4 @@ public class SineWave implements SWTApplication { public static void main(String[] args) { SWTConsole.run(new SineWave(), 700, 400); } -} ///:~ +} diff --git a/swt/TabbedPane.java b/swt/TabbedPane.java index 59c48dff..8ae76fe5 100644 --- a/swt/TabbedPane.java +++ b/swt/TabbedPane.java @@ -1,4 +1,4 @@ -//: swt/TabbedPane.java +// swt/TabbedPane.java // ©2015 MindView LLC: see Copyright.txt // Placing SWT components in tabbed panes. import swt.util.*; @@ -144,4 +144,4 @@ public class TabbedPane implements SWTApplication { public static void main(String[] args) { SWTConsole.run(new TabbedPane(), 800, 600); } -} ///:~ +} diff --git a/swt/util/SWTApplication.java b/swt/util/SWTApplication.java index 75735634..54ea582b 100644 --- a/swt/util/SWTApplication.java +++ b/swt/util/SWTApplication.java @@ -1,8 +1,8 @@ -//: swt/util/SWTApplication.java +// swt/util/SWTApplication.java // ©2015 MindView LLC: see Copyright.txt package swt.util; import org.eclipse.swt.widgets.*; public interface SWTApplication { void createContents(Composite parent); -} ///:~ +} diff --git a/swt/util/SWTConsole.java b/swt/util/SWTConsole.java index fcdef505..df10cf6a 100644 --- a/swt/util/SWTConsole.java +++ b/swt/util/SWTConsole.java @@ -1,4 +1,4 @@ -//: swt/util/SWTConsole.java +// swt/util/SWTConsole.java // ©2015 MindView LLC: see Copyright.txt package swt.util; import org.eclipse.swt.widgets.*; @@ -18,4 +18,4 @@ public class SWTConsole { } display.dispose(); } -} ///:~ +} diff --git a/typeinfo/AnonymousImplementation.java b/typeinfo/AnonymousImplementation.java index 404cbd7a..38b086ed 100644 --- a/typeinfo/AnonymousImplementation.java +++ b/typeinfo/AnonymousImplementation.java @@ -1,4 +1,4 @@ -//: typeinfo/AnonymousImplementation.java +// typeinfo/AnonymousImplementation.java // ©2015 MindView LLC: see Copyright.txt // Anonymous inner classes can't hide from reflection. import typeinfo.interfacea.*; @@ -27,11 +27,12 @@ public class AnonymousImplementation { HiddenImplementation.callHiddenMethod(a, "v"); HiddenImplementation.callHiddenMethod(a, "w"); } -} /* Output: +} +/* Output: public C.f() AnonymousA$1 public C.g() package C.u() protected C.v() private C.w() -*///:~ +*/ diff --git a/typeinfo/BoundedClassReferences.java b/typeinfo/BoundedClassReferences.java index ccd06119..a9b50e42 100644 --- a/typeinfo/BoundedClassReferences.java +++ b/typeinfo/BoundedClassReferences.java @@ -1,4 +1,4 @@ -//: typeinfo/BoundedClassReferences.java +// typeinfo/BoundedClassReferences.java // ©2015 MindView LLC: see Copyright.txt public class BoundedClassReferences { @@ -8,4 +8,5 @@ public class BoundedClassReferences { bounded = Number.class; // Or anything else derived from Number. } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/typeinfo/ClassCasts.java b/typeinfo/ClassCasts.java index 288a593d..54e95844 100644 --- a/typeinfo/ClassCasts.java +++ b/typeinfo/ClassCasts.java @@ -1,4 +1,4 @@ -//: typeinfo/ClassCasts.java +// typeinfo/ClassCasts.java // ©2015 MindView LLC: see Copyright.txt class Building {} @@ -11,4 +11,5 @@ public class ClassCasts { House h = houseType.cast(b); h = (House)b; // ... or just do this. } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/typeinfo/ClassInitialization.java b/typeinfo/ClassInitialization.java index 473e632a..5b53a8c7 100644 --- a/typeinfo/ClassInitialization.java +++ b/typeinfo/ClassInitialization.java @@ -1,4 +1,4 @@ -//: typeinfo/ClassInitialization.java +// typeinfo/ClassInitialization.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -40,7 +40,8 @@ public class ClassInitialization { System.out.println("After creating Initable3 ref"); System.out.println(Initable3.staticNonFinal); } -} /* Output: +} +/* Output: After creating Initable ref 47 Initializing Initable @@ -50,4 +51,4 @@ Initializing Initable2 Initializing Initable3 After creating Initable3 ref 74 -*///:~ +*/ diff --git a/typeinfo/FamilyVsExactType.java b/typeinfo/FamilyVsExactType.java index 47235b20..cab20c3c 100644 --- a/typeinfo/FamilyVsExactType.java +++ b/typeinfo/FamilyVsExactType.java @@ -1,4 +1,4 @@ -//: typeinfo/FamilyVsExactType.java +// typeinfo/FamilyVsExactType.java // ©2015 MindView LLC: see Copyright.txt // The difference between instanceof and class package typeinfo; @@ -28,7 +28,8 @@ public class FamilyVsExactType { test(new Base()); test(new Derived()); } -} /* Output: +} +/* Output: Testing x of type class typeinfo.Base x instanceof Base true x instanceof Derived false @@ -47,4 +48,4 @@ x.getClass() == Base.class false x.getClass() == Derived.class true x.getClass().equals(Base.class)) false x.getClass().equals(Derived.class)) true -*///:~ +*/ diff --git a/typeinfo/FilledList.java b/typeinfo/FilledList.java index 9ff41e2a..1be93171 100644 --- a/typeinfo/FilledList.java +++ b/typeinfo/FilledList.java @@ -1,4 +1,4 @@ -//: typeinfo/FilledList.java +// typeinfo/FilledList.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -28,6 +28,7 @@ public class FilledList { new FilledList<>(CountedInteger.class); System.out.println(fl.create(15)); } -} /* Output: +} +/* Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] -*///:~ +*/ diff --git a/typeinfo/GenericClassReferences.java b/typeinfo/GenericClassReferences.java index d9250f88..39afbfa7 100644 --- a/typeinfo/GenericClassReferences.java +++ b/typeinfo/GenericClassReferences.java @@ -1,4 +1,4 @@ -//: typeinfo/GenericClassReferences.java +// typeinfo/GenericClassReferences.java // ©2015 MindView LLC: see Copyright.txt public class GenericClassReferences { @@ -9,4 +9,5 @@ public class GenericClassReferences { intClass = double.class; // genericIntClass = double.class; // Illegal } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/typeinfo/HiddenImplementation.java b/typeinfo/HiddenImplementation.java index bffb0d3b..bb5887b3 100644 --- a/typeinfo/HiddenImplementation.java +++ b/typeinfo/HiddenImplementation.java @@ -1,4 +1,4 @@ -//: typeinfo/HiddenImplementation.java +// typeinfo/HiddenImplementation.java // ©2015 MindView LLC: see Copyright.txt // Sneaking around package hiding. import typeinfo.interfacea.*; @@ -28,11 +28,12 @@ public class HiddenImplementation { g.setAccessible(true); g.invoke(a); } -} /* Output: +} +/* Output: public C.f() typeinfo.packageaccess.C public C.g() package C.u() protected C.v() private C.w() -*///:~ +*/ diff --git a/typeinfo/InnerImplementation.java b/typeinfo/InnerImplementation.java index 3067b475..72b19fe6 100644 --- a/typeinfo/InnerImplementation.java +++ b/typeinfo/InnerImplementation.java @@ -1,4 +1,4 @@ -//: typeinfo/InnerImplementation.java +// typeinfo/InnerImplementation.java // ©2015 MindView LLC: see Copyright.txt // Private inner classes can't hide from reflection. import typeinfo.interfacea.*; @@ -26,11 +26,12 @@ public class InnerImplementation { HiddenImplementation.callHiddenMethod(a, "v"); HiddenImplementation.callHiddenMethod(a, "w"); } -} /* Output: +} +/* Output: public C.f() InnerA$C public C.g() package C.u() protected C.v() private C.w() -*///:~ +*/ diff --git a/typeinfo/InterfaceViolation.java b/typeinfo/InterfaceViolation.java index 5fd150be..c026d2bd 100644 --- a/typeinfo/InterfaceViolation.java +++ b/typeinfo/InterfaceViolation.java @@ -1,4 +1,4 @@ -//: typeinfo/InterfaceViolation.java +// typeinfo/InterfaceViolation.java // ©2015 MindView LLC: see Copyright.txt // Sneaking around an interface. import typeinfo.interfacea.*; @@ -19,6 +19,7 @@ public class InterfaceViolation { b.g(); } } -} /* Output: +} +/* Output: B -*///:~ +*/ diff --git a/typeinfo/ModifyingPrivateFields.java b/typeinfo/ModifyingPrivateFields.java index 98042311..fab2d59b 100644 --- a/typeinfo/ModifyingPrivateFields.java +++ b/typeinfo/ModifyingPrivateFields.java @@ -1,4 +1,4 @@ -//: typeinfo/ModifyingPrivateFields.java +// typeinfo/ModifyingPrivateFields.java // ©2015 MindView LLC: see Copyright.txt import java.lang.reflect.*; @@ -32,7 +32,8 @@ public class ModifyingPrivateFields { f.set(pf, "No, you're not!"); System.out.println(pf); } -} /* Output: +} +/* Output: i = 1, I'm totally safe, Am I safe? f.getInt(pf): 1 i = 47, I'm totally safe, Am I safe? @@ -40,4 +41,4 @@ f.get(pf): I'm totally safe i = 47, I'm totally safe, Am I safe? f.get(pf): Am I safe? i = 47, I'm totally safe, No, you're not! -*///:~ +*/ diff --git a/typeinfo/NullRobot.java b/typeinfo/NullRobot.java index 481d8e6c..b107ed4b 100644 --- a/typeinfo/NullRobot.java +++ b/typeinfo/NullRobot.java @@ -1,4 +1,4 @@ -//: typeinfo/NullRobot.java +// typeinfo/NullRobot.java // ©2015 MindView LLC: see Copyright.txt // Using a dynamic proxy to create a Null Object. import java.lang.reflect.*; @@ -45,7 +45,8 @@ public class NullRobot { for(Robot bot : bots) Robot.Test.test(bot); } -} /* Output: +} +/* Output: Robot name: SnowBee Robot model: SnowBot Series 11 SnowBee can shovel snow @@ -57,4 +58,4 @@ SnowBee clearing roof [Null Robot] Robot name: SnowRemovalRobot NullRobot Robot model: SnowRemovalRobot NullRobot -*///:~ +*/ diff --git a/typeinfo/Operation.java b/typeinfo/Operation.java index 2051cae6..ee899747 100644 --- a/typeinfo/Operation.java +++ b/typeinfo/Operation.java @@ -1,7 +1,7 @@ -//: typeinfo/Operation.java +// typeinfo/Operation.java // ©2015 MindView LLC: see Copyright.txt public interface Operation { String description(); void command(); -} ///:~ +} diff --git a/typeinfo/Person.java b/typeinfo/Person.java index 979884ec..f12d2f86 100644 --- a/typeinfo/Person.java +++ b/typeinfo/Person.java @@ -1,4 +1,4 @@ -//: typeinfo/Person.java +// typeinfo/Person.java // ©2015 MindView LLC: see Copyright.txt // A class with a Null Object. import com.mindviewinc.util.*; @@ -24,4 +24,4 @@ class Person { public String toString() { return "NullPerson"; } } public static final Person NULL = new NullPerson(); -} ///:~ +} diff --git a/typeinfo/PetCount.java b/typeinfo/PetCount.java index 9e0ce7c3..db85c10e 100644 --- a/typeinfo/PetCount.java +++ b/typeinfo/PetCount.java @@ -1,4 +1,4 @@ -//: typeinfo/PetCount.java +// typeinfo/PetCount.java // ©2015 MindView LLC: see Copyright.txt // Using instanceof. import typeinfo.pets.*; @@ -53,10 +53,11 @@ public class PetCount { public static void main(String[] args) { countPets(new ForNameCreator()); } -} /* Output: +} +/* Output: Rat Manx Cymric Mutt Pug Cymric Pug Manx Cymric Rat EgyptianMau Hamster EgyptianMau Mutt Mutt Cymric Mouse Pug Mouse Cymric {EgyptianMau=2, Pug=3, Rat=2, Cymric=5, Mouse=2, Cat=9, Manx=7, Rodent=5, Mutt=3, Dog=6, Pet=20, Hamster=1} -*///:~ +*/ diff --git a/typeinfo/PetCount2.java b/typeinfo/PetCount2.java index 5b1eddc3..ddc071ff 100644 --- a/typeinfo/PetCount2.java +++ b/typeinfo/PetCount2.java @@ -1,4 +1,4 @@ -//: typeinfo/PetCount2.java +// typeinfo/PetCount2.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; @@ -6,10 +6,11 @@ public class PetCount2 { public static void main(String[] args) { PetCount.countPets(Pets.creator); } -} /* Output: +} +/* Output: Rat Manx Cymric Mutt Pug Cymric Pug Manx Cymric Rat EgyptianMau Hamster EgyptianMau Mutt Mutt Cymric Mouse Pug Mouse Cymric {EgyptianMau=2, Pug=3, Rat=2, Cymric=5, Mouse=2, Cat=9, Manx=7, Rodent=5, Mutt=3, Dog=6, Pet=20, Hamster=1} -*///:~ +*/ diff --git a/typeinfo/PetCount3.java b/typeinfo/PetCount3.java index bc6eeba9..45d6e4d5 100644 --- a/typeinfo/PetCount3.java +++ b/typeinfo/PetCount3.java @@ -1,4 +1,4 @@ -//: typeinfo/PetCount3.java +// typeinfo/PetCount3.java // ©2015 MindView LLC: see Copyright.txt // Using isInstance() import typeinfo.pets.*; @@ -43,10 +43,11 @@ public class PetCount3 { print(); print(petCount); } -} /* Output: +} +/* Output: Rat Manx Cymric Mutt Pug Cymric Pug Manx Cymric Rat EgyptianMau Hamster EgyptianMau Mutt Mutt Cymric Mouse Pug Mouse Cymric {Pet=20, Dog=6, Cat=9, Rodent=5, Mutt=3, Pug=3, EgyptianMau=2, Manx=7, Cymric=5, Rat=2, Mouse=2, Hamster=1} -*///:~ +*/ diff --git a/typeinfo/PetCount4.java b/typeinfo/PetCount4.java index 666d2da1..a51acc78 100644 --- a/typeinfo/PetCount4.java +++ b/typeinfo/PetCount4.java @@ -1,4 +1,4 @@ -//: typeinfo/PetCount4.java +// typeinfo/PetCount4.java // ©2015 MindView LLC: see Copyright.txt import typeinfo.pets.*; import com.mindviewinc.util.*; @@ -14,10 +14,11 @@ public class PetCount4 { print(); print(counter); } -} /* Output: +} +/* Output: Rat Manx Cymric Mutt Pug Cymric Pug Manx Cymric Rat EgyptianMau Hamster EgyptianMau Mutt Mutt Cymric Mouse Pug Mouse Cymric {Rodent=5, Cat=9, Cymric=5, Manx=7, Hamster=1, Mouse=2, Pug=3, Dog=6, Rat=2, Pet=20, EgyptianMau=2, Mutt=3} -*///:~ +*/ diff --git a/typeinfo/Position.java b/typeinfo/Position.java index d7ae29ab..d9e40770 100644 --- a/typeinfo/Position.java +++ b/typeinfo/Position.java @@ -1,4 +1,4 @@ -//: typeinfo/Position.java +// typeinfo/Position.java // ©2015 MindView LLC: see Copyright.txt class Position { @@ -28,4 +28,4 @@ class Position { public String toString() { return "Position: " + title + " " + person; } -} ///:~ +} diff --git a/typeinfo/RegisteredFactories.java b/typeinfo/RegisteredFactories.java index 7f6594ef..655cc459 100644 --- a/typeinfo/RegisteredFactories.java +++ b/typeinfo/RegisteredFactories.java @@ -1,4 +1,4 @@ -//: typeinfo/RegisteredFactories.java +// typeinfo/RegisteredFactories.java // ©2015 MindView LLC: see Copyright.txt // Registering Class Factories in the base class. import typeinfo.factory.*; @@ -101,7 +101,8 @@ public class RegisteredFactories { for(int i = 0; i < 10; i++) System.out.println(Part.createRandom()); } -} /* Output: +} +/* Output: GeneratorBelt CabinAirFilter GeneratorBelt @@ -112,4 +113,4 @@ FuelFilter PowerSteeringBelt PowerSteeringBelt FuelFilter -*///:~ +*/ diff --git a/typeinfo/Robot.java b/typeinfo/Robot.java index f419dca5..ffe317e1 100644 --- a/typeinfo/Robot.java +++ b/typeinfo/Robot.java @@ -1,4 +1,4 @@ -//: typeinfo/Robot.java +// typeinfo/Robot.java // ©2015 MindView LLC: see Copyright.txt import com.mindviewinc.util.*; import java.util.*; @@ -19,4 +19,4 @@ public interface Robot { } } } -} ///:~ +} diff --git a/typeinfo/SelectingMethods.java b/typeinfo/SelectingMethods.java index 2048a1c2..de590700 100644 --- a/typeinfo/SelectingMethods.java +++ b/typeinfo/SelectingMethods.java @@ -1,4 +1,4 @@ -//: typeinfo/SelectingMethods.java +// typeinfo/SelectingMethods.java // ©2015 MindView LLC: see Copyright.txt // Looking for particular methods in a dynamic proxy. import java.lang.reflect.*; @@ -50,10 +50,11 @@ class SelectingMethods { proxy.interesting("bonobo"); proxy.boring3(); } -} /* Output: +} +/* Output: boring1 boring2 Proxy detected the interesting method interesting bonobo boring3 -*///:~ +*/ diff --git a/typeinfo/Shapes.java b/typeinfo/Shapes.java index 2aa7cbea..a9e8eec6 100644 --- a/typeinfo/Shapes.java +++ b/typeinfo/Shapes.java @@ -1,4 +1,4 @@ -//: typeinfo/Shapes.java +// typeinfo/Shapes.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -31,8 +31,9 @@ public class Shapes { for(Shape shape : shapeList) shape.draw(); } -} /* Output: +} +/* Output: Circle.draw() Square.draw() Triangle.draw() -*///:~ +*/ diff --git a/typeinfo/ShowMethods.java b/typeinfo/ShowMethods.java index 95c20dbf..eae31737 100644 --- a/typeinfo/ShowMethods.java +++ b/typeinfo/ShowMethods.java @@ -1,4 +1,4 @@ -//: typeinfo/ShowMethods.java +// typeinfo/ShowMethods.java // ©2015 MindView LLC: see Copyright.txt // Using reflection to show all the methods of a class, // even if the methods are defined in the base class. @@ -50,7 +50,8 @@ public class ShowMethods { print("No such class: " + e); } } -} /* Output: +} +/* Output: public static void main(String[]) public final void wait() throws InterruptedException public final void wait(long,int) throws @@ -64,4 +65,4 @@ public final native Class getClass() public final native void notify() public final native void notifyAll() public ShowMethods() -*///:~ +*/ diff --git a/typeinfo/SimpleDynamicProxy.java b/typeinfo/SimpleDynamicProxy.java index 0c120c7e..c361304b 100644 --- a/typeinfo/SimpleDynamicProxy.java +++ b/typeinfo/SimpleDynamicProxy.java @@ -1,4 +1,4 @@ -//: typeinfo/SimpleDynamicProxy.java +// typeinfo/SimpleDynamicProxy.java // ©2015 MindView LLC: see Copyright.txt import java.lang.reflect.*; @@ -35,7 +35,8 @@ class SimpleDynamicProxy { new DynamicProxyHandler(real)); consumer(proxy); } -} /* Output: +} +/* Output: doSomething somethingElse bonobo **** proxy: class $Proxy0, method: public abstract void @@ -46,4 +47,4 @@ Interface.somethingElse(java.lang.String), args: [Ljava.lang.Object;@1c7c054 bonobo somethingElse bonobo -*///:~ +*/ diff --git a/typeinfo/SimpleProxyDemo.java b/typeinfo/SimpleProxyDemo.java index 063e0794..e5e22056 100644 --- a/typeinfo/SimpleProxyDemo.java +++ b/typeinfo/SimpleProxyDemo.java @@ -1,4 +1,4 @@ -//: typeinfo/SimpleProxyDemo.java +// typeinfo/SimpleProxyDemo.java // ©2015 MindView LLC: see Copyright.txt import static com.mindviewinc.util.Print.*; @@ -42,11 +42,12 @@ class SimpleProxyDemo { consumer(new RealObject()); consumer(new SimpleProxy(new RealObject())); } -} /* Output: +} +/* Output: doSomething somethingElse bonobo SimpleProxy doSomething doSomething SimpleProxy somethingElse bonobo somethingElse bonobo -*///:~ +*/ diff --git a/typeinfo/SnowRemovalRobot.java b/typeinfo/SnowRemovalRobot.java index 9634a133..bd72bbe6 100644 --- a/typeinfo/SnowRemovalRobot.java +++ b/typeinfo/SnowRemovalRobot.java @@ -1,4 +1,4 @@ -//: typeinfo/SnowRemovalRobot.java +// typeinfo/SnowRemovalRobot.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -46,7 +46,8 @@ public class SnowRemovalRobot implements Robot { public static void main(String[] args) { Robot.Test.test(new SnowRemovalRobot("Slusher")); } -} /* Output: +} +/* Output: Robot name: Slusher Robot model: SnowBot Series 11 Slusher can shovel snow @@ -55,4 +56,4 @@ Slusher can chip ice Slusher chipping ice Slusher can clear the roof Slusher clearing roof -*///:~ +*/ diff --git a/typeinfo/Staff.java b/typeinfo/Staff.java index f49ba2d3..92bc1c29 100644 --- a/typeinfo/Staff.java +++ b/typeinfo/Staff.java @@ -1,4 +1,4 @@ -//: typeinfo/Staff.java +// typeinfo/Staff.java // ©2015 MindView LLC: see Copyright.txt import java.util.*; @@ -44,7 +44,8 @@ public class Staff extends ArrayList { new Person("Bob", "Coder", "Bright Light City")); System.out.println(staff); } -} /* Output: +} +/* Output: [Position: President Person: Me Last The Top, Lonely At, Position: CTO NullPerson, Position: Marketing Manager NullPerson, Position: Product Manager NullPerson, Position: @@ -54,4 +55,4 @@ Position: Software Engineer NullPerson, Position: Software Engineer NullPerson, Position: Software Engineer NullPerson, Position: Test Engineer NullPerson, Position: Technical Writer NullPerson] -*///:~ +*/ diff --git a/typeinfo/SweetShop.java b/typeinfo/SweetShop.java index e4519f69..b49f9ec8 100644 --- a/typeinfo/SweetShop.java +++ b/typeinfo/SweetShop.java @@ -1,4 +1,4 @@ -//: typeinfo/SweetShop.java +// typeinfo/SweetShop.java // ©2015 MindView LLC: see Copyright.txt // Examination of the way the class loader works. import static com.mindviewinc.util.Print.*; @@ -29,7 +29,8 @@ public class SweetShop { new Cookie(); print("After creating Cookie"); } -} /* Output: +} +/* Output: inside main Loading Candy After creating Candy @@ -37,4 +38,4 @@ Loading Gum After Class.forName("Gum") Loading Cookie After creating Cookie -*///:~ +*/ diff --git a/typeinfo/WildcardClassReferences.java b/typeinfo/WildcardClassReferences.java index b4736ed8..cd694b37 100644 --- a/typeinfo/WildcardClassReferences.java +++ b/typeinfo/WildcardClassReferences.java @@ -1,4 +1,4 @@ -//: typeinfo/WildcardClassReferences.java +// typeinfo/WildcardClassReferences.java // ©2015 MindView LLC: see Copyright.txt public class WildcardClassReferences { @@ -6,4 +6,5 @@ public class WildcardClassReferences { Class intClass = int.class; intClass = double.class; } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/typeinfo/factory/Factory.java b/typeinfo/factory/Factory.java index 3ba90e6e..1cbe2e9d 100644 --- a/typeinfo/factory/Factory.java +++ b/typeinfo/factory/Factory.java @@ -1,4 +1,4 @@ -//: typeinfo/factory/Factory.java +// typeinfo/factory/Factory.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.factory; -public interface Factory { T create(); } ///:~ +public interface Factory { T create(); } diff --git a/typeinfo/interfacea/A.java b/typeinfo/interfacea/A.java index 343cb0ba..3a25e258 100644 --- a/typeinfo/interfacea/A.java +++ b/typeinfo/interfacea/A.java @@ -1,7 +1,7 @@ -//: typeinfo/interfacea/A.java +// typeinfo/interfacea/A.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.interfacea; public interface A { void f(); -} ///:~ +} diff --git a/typeinfo/packageaccess/HiddenC.java b/typeinfo/packageaccess/HiddenC.java index e03b20c1..facb59e8 100644 --- a/typeinfo/packageaccess/HiddenC.java +++ b/typeinfo/packageaccess/HiddenC.java @@ -1,4 +1,4 @@ -//: typeinfo/packageaccess/HiddenC.java +// typeinfo/packageaccess/HiddenC.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.packageaccess; import typeinfo.interfacea.*; @@ -15,4 +15,4 @@ class C implements A { public class HiddenC { public static A makeA() { return new C(); } -} ///:~ +} diff --git a/typeinfo/pets/Cat.java b/typeinfo/pets/Cat.java index 8ba1d165..8d23171e 100644 --- a/typeinfo/pets/Cat.java +++ b/typeinfo/pets/Cat.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Cat.java +// typeinfo/pets/Cat.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Cat extends Pet { public Cat(String name) { super(name); } public Cat() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Cymric.java b/typeinfo/pets/Cymric.java index 612a94a8..fb4bb635 100644 --- a/typeinfo/pets/Cymric.java +++ b/typeinfo/pets/Cymric.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Cymric.java +// typeinfo/pets/Cymric.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Cymric extends Manx { public Cymric(String name) { super(name); } public Cymric() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Dog.java b/typeinfo/pets/Dog.java index 7ab622c9..53ab03f8 100644 --- a/typeinfo/pets/Dog.java +++ b/typeinfo/pets/Dog.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Dog.java +// typeinfo/pets/Dog.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Dog extends Pet { public Dog(String name) { super(name); } public Dog() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/EgyptianMau.java b/typeinfo/pets/EgyptianMau.java index 1625270d..4a938c02 100644 --- a/typeinfo/pets/EgyptianMau.java +++ b/typeinfo/pets/EgyptianMau.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/EgyptianMau.java +// typeinfo/pets/EgyptianMau.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class EgyptianMau extends Cat { public EgyptianMau(String name) { super(name); } public EgyptianMau() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/ForNameCreator.java b/typeinfo/pets/ForNameCreator.java index b5c736fd..aa260a80 100644 --- a/typeinfo/pets/ForNameCreator.java +++ b/typeinfo/pets/ForNameCreator.java @@ -1,4 +1,4 @@ -//: typeinfo/pets/ForNameCreator.java +// typeinfo/pets/ForNameCreator.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; import java.util.*; @@ -30,4 +30,4 @@ public class ForNameCreator extends PetCreator { static { loader(); } @Override public List> types() {return types;} -} ///:~ +} diff --git a/typeinfo/pets/Hamster.java b/typeinfo/pets/Hamster.java index 5c5a2457..13ded324 100644 --- a/typeinfo/pets/Hamster.java +++ b/typeinfo/pets/Hamster.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Hamster.java +// typeinfo/pets/Hamster.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Hamster extends Rodent { public Hamster(String name) { super(name); } public Hamster() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Individual.java b/typeinfo/pets/Individual.java index 2fa091c3..b0e273aa 100644 --- a/typeinfo/pets/Individual.java +++ b/typeinfo/pets/Individual.java @@ -1,4 +1,4 @@ -//: typeinfo/pets/Individual.java +// typeinfo/pets/Individual.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; @@ -43,4 +43,4 @@ public class Individual implements Comparable { } return (arg.id < id ? -1 : (arg.id == id ? 0 : 1)); } -} ///:~ +} diff --git a/typeinfo/pets/LiteralPetCreator.java b/typeinfo/pets/LiteralPetCreator.java index a4d81a66..d2f0bf70 100644 --- a/typeinfo/pets/LiteralPetCreator.java +++ b/typeinfo/pets/LiteralPetCreator.java @@ -1,4 +1,4 @@ -//: typeinfo/pets/LiteralPetCreator.java +// typeinfo/pets/LiteralPetCreator.java // ©2015 MindView LLC: see Copyright.txt // Using class literals. package typeinfo.pets; @@ -23,9 +23,10 @@ public class LiteralPetCreator extends PetCreator { public static void main(String[] args) { System.out.println(types); } -} /* Output: +} +/* Output: [class typeinfo.pets.Mutt, class typeinfo.pets.Pug, class typeinfo.pets.EgyptianMau, class typeinfo.pets.Manx, class typeinfo.pets.Cymric, class typeinfo.pets.Rat, class typeinfo.pets.Mouse, class typeinfo.pets.Hamster] -*///:~ +*/ diff --git a/typeinfo/pets/Manx.java b/typeinfo/pets/Manx.java index 327378cc..4144d383 100644 --- a/typeinfo/pets/Manx.java +++ b/typeinfo/pets/Manx.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Manx.java +// typeinfo/pets/Manx.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Manx extends Cat { public Manx(String name) { super(name); } public Manx() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Mouse.java b/typeinfo/pets/Mouse.java index d4c53bef..3e96e4c9 100644 --- a/typeinfo/pets/Mouse.java +++ b/typeinfo/pets/Mouse.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Mouse.java +// typeinfo/pets/Mouse.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Mouse extends Rodent { public Mouse(String name) { super(name); } public Mouse() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Mutt.java b/typeinfo/pets/Mutt.java index 5a1f6722..5e1d336f 100644 --- a/typeinfo/pets/Mutt.java +++ b/typeinfo/pets/Mutt.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Mutt.java +// typeinfo/pets/Mutt.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Mutt extends Dog { public Mutt(String name) { super(name); } public Mutt() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Person.java b/typeinfo/pets/Person.java index aa98366c..bd4c7fc0 100644 --- a/typeinfo/pets/Person.java +++ b/typeinfo/pets/Person.java @@ -1,7 +1,7 @@ -//: typeinfo/pets/Person.java +// typeinfo/pets/Person.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Person extends Individual { public Person(String name) { super(name); } -} ///:~ +} diff --git a/typeinfo/pets/Pet.java b/typeinfo/pets/Pet.java index 4b7a5611..55a5273a 100644 --- a/typeinfo/pets/Pet.java +++ b/typeinfo/pets/Pet.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Pet.java +// typeinfo/pets/Pet.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Pet extends Individual { public Pet(String name) { super(name); } public Pet() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/PetCreator.java b/typeinfo/pets/PetCreator.java index a57c2e26..dc5ae973 100644 --- a/typeinfo/pets/PetCreator.java +++ b/typeinfo/pets/PetCreator.java @@ -1,4 +1,4 @@ -//: typeinfo/pets/PetCreator.java +// typeinfo/pets/PetCreator.java // ©2015 MindView LLC: see Copyright.txt // Creates random sequences of Pets. package typeinfo.pets; @@ -28,4 +28,4 @@ public abstract class PetCreator { Collections.addAll(result, createArray(size)); return result; } -} ///:~ +} diff --git a/typeinfo/pets/Pets.java b/typeinfo/pets/Pets.java index dbd97fbe..79a4871c 100644 --- a/typeinfo/pets/Pets.java +++ b/typeinfo/pets/Pets.java @@ -1,4 +1,4 @@ -//: typeinfo/pets/Pets.java +// typeinfo/pets/Pets.java // ©2015 MindView LLC: see Copyright.txt // Facade to produce a default PetCreator. package typeinfo.pets; @@ -16,4 +16,4 @@ public class Pets { public static ArrayList arrayList(int size) { return creator.arrayList(size); } -} ///:~ +} diff --git a/typeinfo/pets/Pug.java b/typeinfo/pets/Pug.java index c9738734..825750d4 100644 --- a/typeinfo/pets/Pug.java +++ b/typeinfo/pets/Pug.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Pug.java +// typeinfo/pets/Pug.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Pug extends Dog { public Pug(String name) { super(name); } public Pug() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Rat.java b/typeinfo/pets/Rat.java index df93d7ad..9273f52a 100644 --- a/typeinfo/pets/Rat.java +++ b/typeinfo/pets/Rat.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Rat.java +// typeinfo/pets/Rat.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Rat extends Rodent { public Rat(String name) { super(name); } public Rat() { super(); } -} ///:~ +} diff --git a/typeinfo/pets/Rodent.java b/typeinfo/pets/Rodent.java index fa34b24c..38438f4f 100644 --- a/typeinfo/pets/Rodent.java +++ b/typeinfo/pets/Rodent.java @@ -1,8 +1,8 @@ -//: typeinfo/pets/Rodent.java +// typeinfo/pets/Rodent.java // ©2015 MindView LLC: see Copyright.txt package typeinfo.pets; public class Rodent extends Pet { public Rodent(String name) { super(name); } public Rodent() { super(); } -} ///:~ +} diff --git a/typeinfo/toys/GenericToyTest.java b/typeinfo/toys/GenericToyTest.java index bf717fe3..3e882818 100644 --- a/typeinfo/toys/GenericToyTest.java +++ b/typeinfo/toys/GenericToyTest.java @@ -1,4 +1,4 @@ -//: typeinfo/toys/GenericToyTest.java +// typeinfo/toys/GenericToyTest.java // ©2015 MindView LLC: see Copyright.txt // Testing class Class. package typeinfo.toys; @@ -14,4 +14,5 @@ public class GenericToyTest { // Only produces Object: Object obj = up.newInstance(); } -} /* Output: (None) *///:~ +} +/* Output: (None) */ diff --git a/typeinfo/toys/ToyTest.java b/typeinfo/toys/ToyTest.java index 4dcd4ea4..3fd0803e 100644 --- a/typeinfo/toys/ToyTest.java +++ b/typeinfo/toys/ToyTest.java @@ -1,4 +1,4 @@ -//: typeinfo/toys/ToyTest.java +// typeinfo/toys/ToyTest.java // ©2015 MindView LLC: see Copyright.txt // Testing class Class. package typeinfo.toys; @@ -52,7 +52,8 @@ public class ToyTest { } printInfo(obj.getClass()); } -} /* Output: +} +/* Output: Class name: typeinfo.toys.FancyToy is interface? [false] Simple name: FancyToy Canonical name : typeinfo.toys.FancyToy @@ -68,4 +69,4 @@ Canonical name : typeinfo.toys.Shoots Class name: typeinfo.toys.Toy is interface? [false] Simple name: Toy Canonical name : typeinfo.toys.Toy -*///:~ +*/ diff --git a/ui/BorderLayout1.java b/ui/BorderLayout1.java index de99d217..a382914b 100644 --- a/ui/BorderLayout1.java +++ b/ui/BorderLayout1.java @@ -1,4 +1,4 @@ -//: ui/BorderLayout1.java +// ui/BorderLayout1.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates BorderLayout. import javax.swing.*; @@ -16,4 +16,4 @@ public class BorderLayout1 extends JFrame { public static void main(String[] args) { run(new BorderLayout1(), 300, 250); } -} ///:~ +} diff --git a/ui/Borders.java b/ui/Borders.java index dbd88306..2c4883b3 100644 --- a/ui/Borders.java +++ b/ui/Borders.java @@ -1,4 +1,4 @@ -//: ui/Borders.java +// ui/Borders.java // ©2015 MindView LLC: see Copyright.txt // Different Swing borders. import javax.swing.*; @@ -35,4 +35,4 @@ public class Borders extends JFrame { public static void main(String[] args) { run(new Borders(), 500, 300); } -} ///:~ +} diff --git a/ui/Button1.java b/ui/Button1.java index 0ee271ef..cac2d02b 100644 --- a/ui/Button1.java +++ b/ui/Button1.java @@ -1,4 +1,4 @@ -//: ui/Button1.java +// ui/Button1.java // ©2015 MindView LLC: see Copyright.txt // Putting buttons on a Swing application. import javax.swing.*; @@ -17,4 +17,4 @@ public class Button1 extends JFrame { public static void main(String[] args) { run(new Button1(), 200, 100); } -} ///:~ +} diff --git a/ui/Button2.java b/ui/Button2.java index 498d1ff2..cd91a294 100644 --- a/ui/Button2.java +++ b/ui/Button2.java @@ -1,4 +1,4 @@ -//: ui/Button2.java +// ui/Button2.java // ©2015 MindView LLC: see Copyright.txt // Responding to button presses. import javax.swing.*; @@ -30,4 +30,4 @@ public class Button2 extends JFrame { public static void main(String[] args) { run(new Button2(), 200, 150); } -} ///:~ +} diff --git a/ui/Button2b.java b/ui/Button2b.java index 4caa7fab..e3b8ac76 100644 --- a/ui/Button2b.java +++ b/ui/Button2b.java @@ -1,4 +1,4 @@ -//: ui/Button2b.java +// ui/Button2b.java // ©2015 MindView LLC: see Copyright.txt // Using anonymous inner classes. import javax.swing.*; @@ -26,4 +26,4 @@ public class Button2b extends JFrame { public static void main(String[] args) { run(new Button2b(), 200, 150); } -} ///:~ +} diff --git a/ui/ButtonGroups.java b/ui/ButtonGroups.java index 9d494dd5..5931b202 100644 --- a/ui/ButtonGroups.java +++ b/ui/ButtonGroups.java @@ -1,4 +1,4 @@ -//: ui/ButtonGroups.java +// ui/ButtonGroups.java // ©2015 MindView LLC: see Copyright.txt // Uses reflection to create groups // of different types of AbstractButton. @@ -51,4 +51,4 @@ public class ButtonGroups extends JFrame { public static void main(String[] args) { run(new ButtonGroups(), 500, 350); } -} ///:~ +} diff --git a/ui/Buttons.java b/ui/Buttons.java index 14a4ae10..4cfc5ceb 100644 --- a/ui/Buttons.java +++ b/ui/Buttons.java @@ -1,4 +1,4 @@ -//: ui/Buttons.java +// ui/Buttons.java // ©2015 MindView LLC: see Copyright.txt // Various Swing buttons. import javax.swing.*; @@ -31,4 +31,4 @@ public class Buttons extends JFrame { public static void main(String[] args) { run(new Buttons(), 350, 200); } -} ///:~ +} diff --git a/ui/CheckBoxes.java b/ui/CheckBoxes.java index 545ac887..558e3aba 100644 --- a/ui/CheckBoxes.java +++ b/ui/CheckBoxes.java @@ -1,4 +1,4 @@ -//: ui/CheckBoxes.java +// ui/CheckBoxes.java // ©2015 MindView LLC: see Copyright.txt // Using JCheckBoxes. import javax.swing.*; @@ -30,4 +30,4 @@ public class CheckBoxes extends JFrame { public static void main(String[] args) { run(new CheckBoxes(), 200, 300); } -} ///:~ +} diff --git a/ui/ColorBoxes.java b/ui/ColorBoxes.java index 41c22c59..f53a544d 100644 --- a/ui/ColorBoxes.java +++ b/ui/ColorBoxes.java @@ -1,4 +1,4 @@ -//: ui/ColorBoxes.java +// ui/ColorBoxes.java // ©2015 MindView LLC: see Copyright.txt // A visual demonstration of threading. import javax.swing.*; @@ -52,4 +52,4 @@ public class ColorBoxes extends JFrame { boxes.setUp(); run(boxes, 500, 400); } -} ///:~ +} diff --git a/ui/ComboBoxes.java b/ui/ComboBoxes.java index 50caab9e..5e74e41d 100644 --- a/ui/ComboBoxes.java +++ b/ui/ComboBoxes.java @@ -1,4 +1,4 @@ -//: ui/ComboBoxes.java +// ui/ComboBoxes.java // ©2015 MindView LLC: see Copyright.txt // Using drop-down lists. import javax.swing.*; @@ -33,4 +33,4 @@ public class ComboBoxes extends JFrame { public static void main(String[] args) { run(new ComboBoxes(), 200, 175); } -} ///:~ +} diff --git a/ui/Dialogs.java b/ui/Dialogs.java index d5907674..67802cf4 100644 --- a/ui/Dialogs.java +++ b/ui/Dialogs.java @@ -1,4 +1,4 @@ -//: ui/Dialogs.java +// ui/Dialogs.java // ©2015 MindView LLC: see Copyright.txt // Creating and using Dialog Boxes. import javax.swing.*; @@ -28,4 +28,4 @@ public class Dialogs extends JFrame { public static void main(String[] args) { run(new Dialogs(), 125, 75); } -} ///:~ +} diff --git a/ui/Faces.java b/ui/Faces.java index 835d90b9..591d9ec4 100644 --- a/ui/Faces.java +++ b/ui/Faces.java @@ -1,4 +1,4 @@ -//: ui/Faces.java +// ui/Faces.java // ©2015 MindView LLC: see Copyright.txt // Icon behavior in JButtons. import javax.swing.*; @@ -50,4 +50,4 @@ public class Faces extends JFrame { public static void main(String[] args) { run(new Faces(), 250, 125); } -} ///:~ +} diff --git a/ui/FileChooserTest.java b/ui/FileChooserTest.java index e17043e4..3b259164 100644 --- a/ui/FileChooserTest.java +++ b/ui/FileChooserTest.java @@ -1,4 +1,4 @@ -//: ui/FileChooserTest.java +// ui/FileChooserTest.java // ©2015 MindView LLC: see Copyright.txt // Demonstration of File dialog boxes. import javax.swing.*; @@ -63,4 +63,4 @@ public class FileChooserTest extends JFrame { public static void main(String[] args) { run(new FileChooserTest(), 250, 150); } -} ///:~ +} diff --git a/ui/FlowLayout1.java b/ui/FlowLayout1.java index 7502a542..aac9c766 100644 --- a/ui/FlowLayout1.java +++ b/ui/FlowLayout1.java @@ -1,4 +1,4 @@ -//: ui/FlowLayout1.java +// ui/FlowLayout1.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates FlowLayout. import javax.swing.*; @@ -14,4 +14,4 @@ public class FlowLayout1 extends JFrame { public static void main(String[] args) { run(new FlowLayout1(), 300, 300); } -} ///:~ +} diff --git a/ui/GridLayout1.java b/ui/GridLayout1.java index 36f988a0..387a52f0 100644 --- a/ui/GridLayout1.java +++ b/ui/GridLayout1.java @@ -1,4 +1,4 @@ -//: ui/GridLayout1.java +// ui/GridLayout1.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates GridLayout. import javax.swing.*; @@ -14,4 +14,4 @@ public class GridLayout1 extends JFrame { public static void main(String[] args) { run(new GridLayout1(), 300, 300); } -} ///:~ +} diff --git a/ui/HTMLButton.java b/ui/HTMLButton.java index b928dd99..932563fc 100644 --- a/ui/HTMLButton.java +++ b/ui/HTMLButton.java @@ -1,4 +1,4 @@ -//: ui/HTMLButton.java +// ui/HTMLButton.java // ©2015 MindView LLC: see Copyright.txt // Putting HTML text on Swing components. import javax.swing.*; @@ -22,4 +22,4 @@ public class HTMLButton extends JFrame { public static void main(String[] args) { run(new HTMLButton(), 200, 500); } -} ///:~ +} diff --git a/ui/HelloLabel.java b/ui/HelloLabel.java index ba69dba6..405b6185 100644 --- a/ui/HelloLabel.java +++ b/ui/HelloLabel.java @@ -1,4 +1,4 @@ -//: ui/HelloLabel.java +// ui/HelloLabel.java // ©2015 MindView LLC: see Copyright.txt import javax.swing.*; import java.util.concurrent.*; @@ -14,4 +14,4 @@ public class HelloLabel { TimeUnit.SECONDS.sleep(1); label.setText("Hey! This is Different!"); } -} ///:~ +} diff --git a/ui/HelloSwing.java b/ui/HelloSwing.java index 6eb03226..a144eafa 100644 --- a/ui/HelloSwing.java +++ b/ui/HelloSwing.java @@ -1,4 +1,4 @@ -//: ui/HelloSwing.java +// ui/HelloSwing.java // ©2015 MindView LLC: see Copyright.txt import javax.swing.*; @@ -9,4 +9,4 @@ public class HelloSwing { frame.setSize(300, 100); frame.setVisible(true); } -} ///:~ +} diff --git a/ui/InterruptableLongRunningCallable.java b/ui/InterruptableLongRunningCallable.java index 46cea77d..f8590334 100644 --- a/ui/InterruptableLongRunningCallable.java +++ b/ui/InterruptableLongRunningCallable.java @@ -1,4 +1,4 @@ -//: ui/InterruptableLongRunningCallable.java +// ui/InterruptableLongRunningCallable.java // ©2015 MindView LLC: see Copyright.txt // Using Callables for long-running tasks. import javax.swing.*; @@ -49,4 +49,4 @@ InterruptableLongRunningCallable extends JFrame { public static void main(String[] args) { run(new InterruptableLongRunningCallable(), 200, 150); } -} ///:~ +} diff --git a/ui/InterruptableLongRunningTask.java b/ui/InterruptableLongRunningTask.java index 10def506..e6bc84be 100644 --- a/ui/InterruptableLongRunningTask.java +++ b/ui/InterruptableLongRunningTask.java @@ -1,4 +1,4 @@ -//: ui/InterruptableLongRunningTask.java +// ui/InterruptableLongRunningTask.java // ©2015 MindView LLC: see Copyright.txt // Long-running tasks in threads. import javax.swing.*; @@ -47,4 +47,4 @@ public class InterruptableLongRunningTask extends JFrame { public static void main(String[] args) { run(new InterruptableLongRunningTask(), 200, 150); } -} ///:~ +} diff --git a/ui/List.java b/ui/List.java index 758e6fce..ac05d78a 100644 --- a/ui/List.java +++ b/ui/List.java @@ -1,4 +1,4 @@ -//: ui/List.java +// ui/List.java // ©2015 MindView LLC: see Copyright.txt import javax.swing.*; import javax.swing.border.*; @@ -56,4 +56,4 @@ public class List extends JFrame { public static void main(String[] args) { run(new List(), 250, 375); } -} ///:~ +} diff --git a/ui/LongRunningTask.java b/ui/LongRunningTask.java index cbd4cbb9..bdbceefa 100644 --- a/ui/LongRunningTask.java +++ b/ui/LongRunningTask.java @@ -1,4 +1,4 @@ -//: ui/LongRunningTask.java +// ui/LongRunningTask.java // ©2015 MindView LLC: see Copyright.txt // A badly designed program. import javax.swing.*; @@ -31,4 +31,4 @@ public class LongRunningTask extends JFrame { public static void main(String[] args) { run(new LongRunningTask(), 200, 150); } -} ///:~ +} diff --git a/ui/LookAndFeel.java b/ui/LookAndFeel.java index ccc7dee7..1204d015 100644 --- a/ui/LookAndFeel.java +++ b/ui/LookAndFeel.java @@ -1,4 +1,4 @@ -//: ui/LookAndFeel.java +// ui/LookAndFeel.java // ©2015 MindView LLC: see Copyright.txt // Selecting different looks & feels. // {Args: motif} @@ -85,4 +85,4 @@ public class LookAndFeel extends JFrame { // any components are created. run(new LookAndFeel(), 300, 300); } -} ///:~ +} diff --git a/ui/Menus.java b/ui/Menus.java index bba5393f..10d708f0 100644 --- a/ui/Menus.java +++ b/ui/Menus.java @@ -1,4 +1,4 @@ -//: ui/Menus.java +// ui/Menus.java // ©2015 MindView LLC: see Copyright.txt // Submenus, check box menu items, swapping menus, // mnemonics (shortcuts) and action commands. @@ -158,4 +158,4 @@ public class Menus extends JFrame { public static void main(String[] args) { run(new Menus(), 300, 200); } -} ///:~ +} diff --git a/ui/MessageBoxes.java b/ui/MessageBoxes.java index f53ecf1d..b46a95da 100644 --- a/ui/MessageBoxes.java +++ b/ui/MessageBoxes.java @@ -1,4 +1,4 @@ -//: ui/MessageBoxes.java +// ui/MessageBoxes.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates JOptionPane. import javax.swing.*; @@ -65,4 +65,4 @@ public class MessageBoxes extends JFrame { public static void main(String[] args) { run(new MessageBoxes(), 200, 200); } -} ///:~ +} diff --git a/ui/MonitoredLongRunningCallable.java b/ui/MonitoredLongRunningCallable.java index 4b35e437..16780e8f 100644 --- a/ui/MonitoredLongRunningCallable.java +++ b/ui/MonitoredLongRunningCallable.java @@ -1,4 +1,4 @@ -//: ui/MonitoredLongRunningCallable.java +// ui/MonitoredLongRunningCallable.java // ©2015 MindView LLC: see Copyright.txt // Displaying task progress with ProgressMonitors. import javax.swing.*; @@ -75,4 +75,4 @@ public class MonitoredLongRunningCallable extends JFrame { public static void main(String[] args) { run(new MonitoredLongRunningCallable(), 200, 500); } -} ///:~ +} diff --git a/ui/Popup.java b/ui/Popup.java index 85e865c8..41bc90ea 100644 --- a/ui/Popup.java +++ b/ui/Popup.java @@ -1,4 +1,4 @@ -//: ui/Popup.java +// ui/Popup.java // ©2015 MindView LLC: see Copyright.txt // Creating popup menus with Swing. import javax.swing.*; @@ -48,4 +48,4 @@ public class Popup extends JFrame { public static void main(String[] args) { run(new Popup(), 300, 200); } -} ///:~ +} diff --git a/ui/Progress.java b/ui/Progress.java index 3899a39a..50875bde 100644 --- a/ui/Progress.java +++ b/ui/Progress.java @@ -1,4 +1,4 @@ -//: ui/Progress.java +// ui/Progress.java // ©2015 MindView LLC: see Copyright.txt // Using sliders, progress bars and progress monitors. import javax.swing.*; @@ -30,4 +30,4 @@ public class Progress extends JFrame { public static void main(String[] args) { run(new Progress(), 300, 200); } -} ///:~ +} diff --git a/ui/RadioButtons.java b/ui/RadioButtons.java index 48440481..9a57c693 100644 --- a/ui/RadioButtons.java +++ b/ui/RadioButtons.java @@ -1,4 +1,4 @@ -//: ui/RadioButtons.java +// ui/RadioButtons.java // ©2015 MindView LLC: see Copyright.txt // Using JRadioButtons. import javax.swing.*; @@ -31,4 +31,4 @@ public class RadioButtons extends JFrame { public static void main(String[] args) { run(new RadioButtons(), 200, 125); } -} ///:~ +} diff --git a/ui/ShowAddListeners.java b/ui/ShowAddListeners.java index 00d021e5..578c272a 100644 --- a/ui/ShowAddListeners.java +++ b/ui/ShowAddListeners.java @@ -1,4 +1,4 @@ -//: ui/ShowAddListeners.java +// ui/ShowAddListeners.java // ©2015 MindView LLC: see Copyright.txt // Display the "addXXXListener" methods of any Swing class. import javax.swing.*; @@ -57,4 +57,4 @@ public class ShowAddListeners extends JFrame { public static void main(String[] args) { run(new ShowAddListeners(), 500, 400); } -} ///:~ +} diff --git a/ui/SimpleMenus.java b/ui/SimpleMenus.java index 68ef423c..0912dd40 100644 --- a/ui/SimpleMenus.java +++ b/ui/SimpleMenus.java @@ -1,4 +1,4 @@ -//: ui/SimpleMenus.java +// ui/SimpleMenus.java // ©2015 MindView LLC: see Copyright.txt import javax.swing.*; import java.awt.*; @@ -35,4 +35,4 @@ public class SimpleMenus extends JFrame { public static void main(String[] args) { run(new SimpleMenus(), 200, 150); } -} ///:~ +} diff --git a/ui/SineWave.java b/ui/SineWave.java index 1a8df612..7dcfcaf3 100644 --- a/ui/SineWave.java +++ b/ui/SineWave.java @@ -1,4 +1,4 @@ -//: ui/SineWave.java +// ui/SineWave.java // ©2015 MindView LLC: see Copyright.txt // Drawing with Swing, using a JSlider. import javax.swing.*; @@ -55,4 +55,4 @@ public class SineWave extends JFrame { public static void main(String[] args) { run(new SineWave(), 700, 400); } -} ///:~ +} diff --git a/ui/SubmitLabelManipulationTask.java b/ui/SubmitLabelManipulationTask.java index 194508f0..071a30ef 100644 --- a/ui/SubmitLabelManipulationTask.java +++ b/ui/SubmitLabelManipulationTask.java @@ -1,4 +1,4 @@ -//: ui/SubmitLabelManipulationTask.java +// ui/SubmitLabelManipulationTask.java // ©2015 MindView LLC: see Copyright.txt import javax.swing.*; import java.util.concurrent.*; @@ -15,4 +15,4 @@ public class SubmitLabelManipulationTask { SwingUtilities.invokeLater(() -> label.setText("Hey! This is Different!")); } -} ///:~ +} diff --git a/ui/SubmitSwingProgram.java b/ui/SubmitSwingProgram.java index 51924fa6..f6782b79 100644 --- a/ui/SubmitSwingProgram.java +++ b/ui/SubmitSwingProgram.java @@ -1,4 +1,4 @@ -//: ui/SubmitSwingProgram.java +// ui/SubmitSwingProgram.java // ©2015 MindView LLC: see Copyright.txt import javax.swing.*; import java.util.concurrent.*; @@ -21,4 +21,4 @@ public class SubmitSwingProgram extends JFrame { SwingUtilities.invokeLater(() -> ssp.label.setText("Hey! This is Different!")); } -} ///:~ +} diff --git a/ui/TabbedPane1.java b/ui/TabbedPane1.java index 61534e00..09aeda81 100644 --- a/ui/TabbedPane1.java +++ b/ui/TabbedPane1.java @@ -1,4 +1,4 @@ -//: ui/TabbedPane1.java +// ui/TabbedPane1.java // ©2015 MindView LLC: see Copyright.txt // Demonstrates the Tabbed Pane. import javax.swing.*; @@ -27,4 +27,4 @@ public class TabbedPane1 extends JFrame { public static void main(String[] args) { run(new TabbedPane1(), 400, 250); } -} ///:~ +} diff --git a/ui/TextArea.java b/ui/TextArea.java index ca372a11..f22f27b2 100644 --- a/ui/TextArea.java +++ b/ui/TextArea.java @@ -1,4 +1,4 @@ -//: ui/TextArea.java +// ui/TextArea.java // ©2015 MindView LLC: see Copyright.txt // Using the JTextArea control. import javax.swing.*; @@ -29,4 +29,4 @@ public class TextArea extends JFrame { public static void main(String[] args) { run(new TextArea(), 475, 425); } -} ///:~ +} diff --git a/ui/TextFields.java b/ui/TextFields.java index 70942bce..f5230cb0 100644 --- a/ui/TextFields.java +++ b/ui/TextFields.java @@ -1,4 +1,4 @@ -//: ui/TextFields.java +// ui/TextFields.java // ©2015 MindView LLC: see Copyright.txt // Text fields and Java events. import javax.swing.*; @@ -87,4 +87,4 @@ class UpperCaseDocument extends PlainDocument { if(upperCase) str = str.toUpperCase(); super.insertString(offset, str, attSet); } -} ///:~ +} diff --git a/ui/TextPane.java b/ui/TextPane.java index 6d0f6891..4489af74 100644 --- a/ui/TextPane.java +++ b/ui/TextPane.java @@ -1,4 +1,4 @@ -//: ui/TextPane.java +// ui/TextPane.java // ©2015 MindView LLC: see Copyright.txt // The JTextPane control is a little editor. import javax.swing.*; @@ -22,4 +22,4 @@ public class TextPane extends JFrame { public static void main(String[] args) { run(new TextPane(), 475, 425); } -} ///:~ +} diff --git a/ui/TicTacToe.java b/ui/TicTacToe.java index 5878cd8e..1acfaaea 100644 --- a/ui/TicTacToe.java +++ b/ui/TicTacToe.java @@ -1,4 +1,4 @@ -//: ui/TicTacToe.java +// ui/TicTacToe.java // ©2015 MindView LLC: see Copyright.txt // Dialog boxes and creating your own components. import javax.swing.*; @@ -82,4 +82,4 @@ public class TicTacToe extends JFrame { public static void main(String[] args) { run(new TicTacToe(), 200, 200); } -} ///:~ +} diff --git a/ui/TrackEvent.java b/ui/TrackEvent.java index 1e41638c..8f80fc45 100644 --- a/ui/TrackEvent.java +++ b/ui/TrackEvent.java @@ -1,4 +1,4 @@ -//: ui/TrackEvent.java +// ui/TrackEvent.java // ©2015 MindView LLC: see Copyright.txt // Show events as they happen. import javax.swing.*; @@ -103,4 +103,4 @@ public class TrackEvent extends JFrame { public static void main(String[] args) { run(new TrackEvent(), 700, 500); } -} ///:~ +} diff --git a/unittesting/JUnitDemo.java b/unittesting/JUnitDemo.java index c8c6c7f6..298dbf3d 100644 --- a/unittesting/JUnitDemo.java +++ b/unittesting/JUnitDemo.java @@ -1,4 +1,4 @@ -//: unittesting/JUnitDemo.java +// unittesting/JUnitDemo.java // ©2015 MindView LLC: see Copyright.txt // Simple use of JUnit to test ArrayList // (Install libraries from www.junit.org) @@ -92,7 +92,8 @@ public class JUnitDemo { org.junit.runner.JUnitCore.runClasses( JUnitDemo.class); } -} /* Output: +} +/* Output: CountedList #0 Running testAddAll() CountedList #1 @@ -103,4 +104,4 @@ CountedList #3 Running testOrder() CountedList #4 Running testReplace() -*///:~ +*/ diff --git a/xml/APerson.java b/xml/APerson.java index 9a199e4b..9de6f31a 100644 --- a/xml/APerson.java +++ b/xml/APerson.java @@ -1,4 +1,4 @@ -//: xml/APerson.java +// xml/APerson.java // ©2015 MindView LLC: see Copyright.txt // Use the XOM library to write and read XML // {Requires: nu.xom.Node; You must install @@ -54,7 +54,8 @@ public class APerson { format(new BufferedOutputStream(new FileOutputStream( "People.xml")), doc); } -} /* Output: +} +/* Output: [Dr. Bunsen Honeydew, Gonzo The Great, Phillip J. Fry] @@ -71,4 +72,4 @@ public class APerson { Fry -*///:~ +*/ diff --git a/xml/People.java b/xml/People.java index ef28dbbd..f14ec64c 100644 --- a/xml/People.java +++ b/xml/People.java @@ -1,4 +1,4 @@ -//: xml/People.java +// xml/People.java // ©2015 MindView LLC: see Copyright.txt // {Requires: nu.xom.Node; You must install // the XOM library from http://www.xom.nu } @@ -19,6 +19,7 @@ public class People extends ArrayList { People p = new People("People.xml"); System.out.println(p); } -} /* Output: +} +/* Output: [Dr. Bunsen Honeydew, Gonzo The Great, Phillip J. Fry] -*///:~ +*/