Most recent and change to (c)

This commit is contained in:
Bruce Eckel 2015-12-15 11:47:04 -08:00
parent 56ec933b8b
commit 79d6d2110f
1055 changed files with 2575 additions and 2085 deletions

View File

@ -15,6 +15,12 @@
To see options, type: ant -p
</description>
<condition property="version1.8">
<equals arg1="1.8" arg2="${ant.java.version}"/>
</condition>
<!--===========================================================-->
<macrodef name="jrun">
<attribute name="cls" default="NOT SET"/>
<attribute name="dirpath" default=""/>
@ -46,6 +52,8 @@
</sequential>
</macrodef>
<!--===========================================================-->
<macrodef name="jrunconsole">
<attribute name="cls" default="NOT SET"/>
<attribute name="dirpath" default=""/>
@ -72,11 +80,10 @@
</sequential>
</macrodef>
<condition property="version1.8">
<equals arg1="1.8" arg2="${ant.java.version}"/>
</condition>
<target name="base">
<!--===========================================================-->
<target name="base"
description="Build all common dependencies">
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../onjava/">
@ -89,12 +96,24 @@
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../polymorphism/music/">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../typeinfo/pets/">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../collections/">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../generics/coffee/">
@ -107,18 +126,13 @@
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../polymorphism/music/">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
</target>
<target
depends="base"
<!--===========================================================-->
<target name="build"
description="Build all classes in this directory"
name="build">
depends="base">
<fail message="Java 8 required" unless="version1.8"/>
<echo message="Building '${chapter}'&#13;"/>
<echo file="${antoutput}" append="true" message="Building '${chapter}'&#13;"/>
@ -134,10 +148,11 @@
<echo file="${antoutput}" append="true" message="Build '${chapter}' succeeded&#13;"/>
</target>
<target
depends="base"
<!--===========================================================-->
<target name="buildw"
description="Build all classes in this directory, enabling 'Unchecked' warnings"
name="buildw">
depends="base">
<fail message="Java 8 required" unless="version1.8"/>
<echo message="Building '${chapter}'&#13;"/>
<echo file="${antoutput}" append="true" message="Building '${chapter}'&#13;"/>
@ -154,10 +169,22 @@
<echo file="${antoutput}" append="true" message="Build '${chapter}' succeeded&#13;"/>
</target>
<target
depends="base"
<!--===========================================================-->
<target name="verifyclean"
description="delete ant verify output files" >
<delete>
<fileset dir="${basedir}" casesensitive="yes">
<include name="**/update_output.bat" />
<include name="**/validate_failures.txt" />
<include name="**/strategies.txt" />
</fileset>
</delete>
<echo message="verifyclean successful"/>
</target>
<target name="verify"
description="Verify output; requires Python 3.5"
name="verify">
depends="verifyclean">
<exec dir="${basedir}" executable="python" failonerror="true">
<arg line="../verify_output.py" />
</exec>

View File

@ -1,5 +1,5 @@
// HelloDate.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// annotations/AtUnitComposition.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Creating non-embedded tests.

View File

@ -1,5 +1,5 @@
// annotations/AtUnitExample1.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations;

View File

@ -1,5 +1,5 @@
// annotations/AtUnitExample2.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Assertions and exceptions can be used in @Tests.

View File

@ -1,5 +1,5 @@
// annotations/AtUnitExample3.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations;

View File

@ -1,5 +1,5 @@
// annotations/AtUnitExample4.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations;
@ -66,16 +66,15 @@ starting
annotations.AtUnitExample4
. words 'All'
(failed)
. scramble1 'brontosauruses'
ntsaueorosurbs
(failed)
. scramble2 'are'
are
. scramble2 'brontosauruses'
tsaeborornussu
. scramble1 'are'
rae
(failed)
(3 tests)
>>> 3 FAILURES <<<
>>> 2 FAILURES <<<
annotations.AtUnitExample4: words
annotations.AtUnitExample4: scramble1
annotations.AtUnitExample4: scramble2
*/

View File

@ -1,5 +1,5 @@
// annotations/AtUnitExample5.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations;

View File

@ -1,5 +1,5 @@
// annotations/AtUnitExternalTest.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Creating non-embedded tests.

View File

@ -1,5 +1,5 @@
// annotations/HashSetTest.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations;

View File

@ -1,5 +1,5 @@
// annotations/PasswordUtils.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// annotations/SimulatingNull.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.lang.annotation.*;

View File

@ -1,5 +1,5 @@
// annotations/StackL.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// A stack built on a linkedList.

View File

@ -1,5 +1,5 @@
// annotations/StackLStringTest.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Applying @Unit to generics.

View File

@ -1,5 +1,5 @@
// annotations/Testable.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations;

View File

@ -1,5 +1,5 @@
// annotations/UseCase.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.lang.annotation.*;

View File

@ -1,5 +1,5 @@
// annotations/UseCaseTracker.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.lang.reflect.*;

View File

@ -1,5 +1,5 @@
// annotations/database/Constraints.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations.database;

View File

@ -1,5 +1,5 @@
// annotations/database/DBTable.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations.database;

View File

@ -1,5 +1,5 @@
// annotations/database/Member.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations.database;

View File

@ -1,5 +1,5 @@
// annotations/database/SQLInteger.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations.database;

View File

@ -1,5 +1,5 @@
// annotations/database/SQLString.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package annotations.database;

View File

@ -1,5 +1,5 @@
// annotations/database/TableCreator.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Reflection-based annotation processor.

View File

@ -1,5 +1,5 @@
// annotations/database/Uniqueness.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Sample of nested annotations

View File

@ -1,5 +1,5 @@
// annotations/ifx/ExtractInterface.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// javac-based annotation processing.

View File

@ -1,5 +1,5 @@
// annotations/ifx/IfaceExtractorProcessor.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// javac-based annotation processing.
@ -50,30 +50,28 @@ extends AbstractProcessor {
}
private void
writeInterfaceFile(String interfaceName) {
try {
try(Writer writer = processingEnv.getFiler()
.createSourceFile(interfaceName)
.openWriter()) {
String packageName = elementUtils
.getPackageOf(interfaceMethods
.get(0)).toString();
writer.write(
"package " + packageName + ";\n");
writer.write("public interface " +
interfaceName + " {\n");
for(Element elem : interfaceMethods) {
ExecutableElement method =
(ExecutableElement)elem;
String signature = " public ";
signature += method.getReturnType()+" ";
signature += method.getSimpleName();
signature += createArgList(
method.getParameters());
System.out.println(signature);
writer.write(signature + ";\n");
}
writer.write("}");
try(Writer writer = processingEnv.getFiler()
.createSourceFile(interfaceName)
.openWriter()) {
String packageName = elementUtils
.getPackageOf(interfaceMethods
.get(0)).toString();
writer.write(
"package " + packageName + ";\n");
writer.write("public interface " +
interfaceName + " {\n");
for(Element elem : interfaceMethods) {
ExecutableElement method =
(ExecutableElement)elem;
String signature = " public ";
signature += method.getReturnType()+" ";
signature += method.getSimpleName();
signature += createArgList(
method.getParameters());
System.out.println(signature);
writer.write(signature + ";\n");
}
writer.write("}");
} catch(Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,5 +1,5 @@
// annotations/ifx/Multiplier.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// javac-based annotation processing.

View File

@ -1,5 +1,5 @@
// annotations/simplest/Simple.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// A bare-bones annotation.

View File

@ -1,5 +1,5 @@
// annotations/simplest/SimpleProcessor.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// A bare-bones annotation processor.

View File

@ -1,5 +1,5 @@
// annotations/simplest/SimpleTest.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Test the "Simple" annotation

View File

@ -1,5 +1,5 @@
// arrays/AlphabeticSearch.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Searching with a Comparator.

View File

@ -1,5 +1,5 @@
// arrays/ArrayOfGenericType.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Arrays of generic types won't compile.

View File

@ -1,5 +1,5 @@
// arrays/ArrayOfGenerics.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// It is possible to create arrays of generics.
@ -29,4 +29,3 @@ public class ArrayOfGenerics {
spheres[i] = new ArrayList<>();
}
}
/* Output: (None) */

View File

@ -1,5 +1,5 @@
// arrays/ArrayOptions.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Initialization & re-assignment of arrays.

View File

@ -1,5 +1,5 @@
// arrays/ArraySearching.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using Arrays.binarySearch().

View File

@ -1,5 +1,5 @@
// arrays/AssemblingMultidimensionalArrays.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Creating multidimensional arrays.

View File

@ -1,5 +1,5 @@
// arrays/AutoboxingArrays.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// arrays/ContainerComparison.java
// ©2016 MindView LLC: see Copyright.txt
// arrays/CollectionComparison.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;
@ -11,7 +11,7 @@ class BerylliumSphere {
public String toString() { return "Sphere " + id; }
}
public class ContainerComparison {
public class CollectionComparison {
public static void main(String[] args) {
BerylliumSphere[] spheres = new BerylliumSphere[10];
for(int i = 0; i < 5; i++)

View File

@ -1,5 +1,5 @@
// arrays/CompType.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Implementing Comparable in a class.

View File

@ -1,5 +1,5 @@
// arrays/ComparatorTest.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Implementing a Comparator for a class.

View File

@ -1,5 +1,5 @@
// arrays/ComparingArrays.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using Arrays.equals()

View File

@ -1,5 +1,5 @@
// arrays/CopyingArrays.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using System.arraycopy()

View File

@ -1,5 +1,5 @@
// arrays/FillingArrays.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using Arrays.fill()

View File

@ -1,5 +1,5 @@
// arrays/IceCream.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Returning arrays from methods.

View File

@ -1,5 +1,5 @@
// arrays/MultiDimWrapperArray.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Multidimensional arrays of "wrapper" objects.

View File

@ -1,5 +1,5 @@
// arrays/MultidimensionalObjectArrays.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// arrays/MultidimensionalPrimitiveArray.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Creating multidimensional arrays.

View File

@ -1,5 +1,5 @@
// arrays/ParameterizedArrayType.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
@ -23,4 +23,3 @@ public class ParameterizedArrayType {
doubles2 = MethodParameter.f(doubles);
}
}
/* Output: (None) */

View File

@ -1,5 +1,5 @@
// arrays/PrimitiveConversionDemonstration.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
# arrays/PythonLists.py
# ©2016 MindView LLC: see Copyright.txt
# (c)2016 MindView LLC: see Copyright.txt
# We make no guarantees that this code is fit for any purpose.
# Visit http://mindviewinc.com/Books/OnJava/ for more book information.

View File

@ -1,5 +1,5 @@
// arrays/RaggedArray.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// arrays/RandomSuppliersTest.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import onjava.*;

View File

@ -1,5 +1,5 @@
// arrays/Reverse.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// The Collections.reverseOrder() Comparator

View File

@ -1,5 +1,5 @@
// arrays/StringSorting.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Sorting an array of Strings.

View File

@ -1,5 +1,5 @@
// arrays/SuppliersTest.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.function.*;

View File

@ -1,5 +1,5 @@
// arrays/TestArrayGeneration.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Test the tools that use generators to fill arrays.

View File

@ -1,5 +1,5 @@
// arrays/TestGenerated.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// arrays/ThreeDWithNew.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -13,10 +13,10 @@
<jrun cls="ArraySearching" />
<jrun cls="AssemblingMultidimensionalArrays" />
<jrun cls="AutoboxingArrays" />
<jrun cls="CollectionComparison" />
<jrun cls="ComparatorTest" />
<jrun cls="ComparingArrays" />
<jrun cls="CompType" />
<jrun cls="ContainerComparison" />
<jrun cls="CopyingArrays" />
<jrun cls="FillingArrays" />
<jrun cls="IceCream" />

View File

@ -1,5 +1,5 @@
// assertions/Assert1.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Non-informative style of assert

View File

@ -1,5 +1,5 @@
// assertions/Assert2.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Assert with an informative message

View File

@ -1,5 +1,5 @@
// assertions/LoaderAssertions.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using the class loader to enable assertions

View File

@ -1,5 +1,5 @@
// assertions/Queue.java
// ©2016 MindView LLC: see Copyright.txt
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Demonstration of Design by Contract (DbC) combined

View File

@ -31,14 +31,14 @@
interfaces/build.xml
innerclasses/build.xml
functional/build.xml
containers/build.xml
collections/build.xml
streams/build.xml
exceptions/build.xml
strings/build.xml
typeinfo/build.xml
generics/build.xml
arrays/build.xml
containersindepth/build.xml
collectionsindepth/build.xml
files/build.xml
enums/build.xml
annotations/build.xml
@ -62,6 +62,46 @@
staticchecking/build.xml
"/>
<filelist id="testablefiles" dir="."
description="All directories that produce auto-testable results"
files="objects/build.xml
operators/build.xml
control/build.xml
housekeeping/build.xml
hiding/build.xml
com/build.xml
reuse/build.xml
polymorphism/build.xml
interfaces/build.xml
innerclasses/build.xml
functional/build.xml
collections/build.xml
streams/build.xml
exceptions/build.xml
strings/build.xml
typeinfo/build.xml
generics/build.xml
arrays/build.xml
collectionsindepth/build.xml
files/build.xml
enums/build.xml
annotations/build.xml
concurrency/build.xml
patterns/build.xml
unittesting/build.xml
assertions/build.xml
references/build.xml
iostreams/build.xml
standardio/build.xml
newio/build.xml
compression/build.xml
serialization/build.xml
preferences/build.xml
logging/build.xml
debugging/build.xml
staticchecking/build.xml
"/>
<target name="run" description="Compiles and runs all examples">
<delete file="errors.txt"/>
<subant>
@ -71,6 +111,15 @@
<antcall target="finish"/>
</target>
<target name="testable" description="Compiles and runs all examples">
<delete file="errors.txt"/>
<subant>
<filelist refid="testablefiles"/>
</subant>
<available file="errors.txt" property="errors"/>
<antcall target="finish"/>
</target>
<target name="build" description="Compiles all examples">
<fail message="Java 8 required" unless="version1.8"/>
<delete file="errors.txt"/>
@ -85,8 +134,21 @@
<echo message="Errors occurred. See errors.txt for information."/>
</target>
<target name="verifyclean"
description="delete ant verify output files" >
<delete>
<fileset dir="${basedir}" casesensitive="yes">
<include name="update_output.bat" />
<include name="validate_failures.txt" />
<include name="strategies.txt" />
</fileset>
</delete>
<echo message="verifyclean successful"/>
</target>
<target name="verify"
description="Verify output; requires Python 3.5">
description="Verify output; requires Python 3.5"
depends="verifyclean">
<exec dir="${basedir}" executable="python" failonerror="true">
<arg line="verify_output.py" />
</exec>

View File

@ -1,5 +1,5 @@
// containers/AdapterMethodIdiom.java
// ©2016 MindView LLC: see Copyright.txt
// collections/AdapterMethodIdiom.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// The "Adapter Method" idiom uses for-in
@ -9,15 +9,16 @@ import java.util.*;
class ReversibleArrayList<T> extends ArrayList<T> {
public ReversibleArrayList(Collection<T> c) { super(c); }
public Iterable<T> reversed() {
return () -> new Iterator<T>() { // <* Describe *>
int current = size() - 1;
@Override
public boolean hasNext() { return current > -1; }
@Override
public T next() { return get(current--); }
@Override
public void remove() { // Not implemented
throw new UnsupportedOperationException();
return new Iterable<T>() {
public Iterator<T> iterator() {
return new Iterator<T>() {
int current = size() - 1;
public boolean hasNext() { return current > -1; }
public T next() { return get(current--); }
public void remove() { // Not implemented
throw new UnsupportedOperationException();
}
};
}
};
}
@ -26,7 +27,7 @@ class ReversibleArrayList<T> extends ArrayList<T> {
public class AdapterMethodIdiom {
public static void main(String[] args) {
ReversibleArrayList<String> ral =
new ReversibleArrayList<>(
new ReversibleArrayList<String>(
Arrays.asList("To be or not to be".split(" ")));
// Grabs the ordinary iterator via iterator():
for(String s : ral)

View File

@ -1,5 +1,5 @@
// containers/AddingGroups.java
// ©2016 MindView LLC: see Copyright.txt
// collections/AddingGroups.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Adding groups of elements to Collection objects.
@ -22,4 +22,3 @@ public class AddingGroups {
// underlying array cannot be resized.
}
}
/* Output: (None) */

View File

@ -1,5 +1,5 @@
// containers/ApplesAndOrangesWithGenerics.java
// ©2016 MindView LLC: see Copyright.txt
// collections/ApplesAndOrangesWithGenerics.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,8 +1,8 @@
// containers/ApplesAndOrangesWithoutGenerics.java
// ©2016 MindView LLC: see Copyright.txt
// collections/ApplesAndOrangesWithoutGenerics.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Simple container use (suppressing compiler warnings)
// Simple collection use (suppressing compiler warnings)
// {ThrowsException}
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/ArrayIsNotIterable.java
// ©2016 MindView LLC: see Copyright.txt
// collections/ArrayIsNotIterable.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/AsListInference.java
// ©2016 MindView LLC: see Copyright.txt
// collections/AsListInference.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Arrays.asList() makes its best guess about type.
@ -34,4 +34,3 @@ public class AsListInference {
new Light(), new Heavy());
}
}
/* Output: (None) */

View File

@ -1,12 +1,12 @@
// containers/ContainerMethods.java
// ©2016 MindView LLC: see Copyright.txt
// collections/CollectionMethods.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import onjava.*;
public class ContainerMethods {
public class CollectionMethods {
public static void main(String[] args) {
ContainerMethodDifferences.main(args);
CollectionMethodDifferences.main(args);
}
}
/* Output:

View File

@ -1,5 +1,5 @@
// containers/CollectionSequence.java
// ©2016 MindView LLC: see Copyright.txt
// collections/CollectionSequence.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
@ -7,12 +7,12 @@ import java.util.*;
public class CollectionSequence
extends AbstractCollection<Pet> {
private Pet[] pets = Pets.createArray(8);
private Pet[] pets = Pets.array(8);
@Override
public int size() { return pets.length; }
@Override
public Iterator<Pet> iterator() {
return new Iterator<Pet>() {
return new Iterator<Pet>() { // (1)
private int index = 0;
@Override
public boolean hasNext() {

View File

@ -1,11 +1,11 @@
// containers/CrossContainerIteration.java
// ©2016 MindView LLC: see Copyright.txt
// collections/CrossCollectionIteration.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
import java.util.*;
public class CrossContainerIteration {
public class CrossCollectionIteration {
public static void display(Iterator<Pet> it) {
while(it.hasNext()) {
Pet p = it.next();
@ -14,7 +14,7 @@ public class CrossContainerIteration {
System.out.println();
}
public static void main(String[] args) {
ArrayList<Pet> pets = Pets.arrayList(8);
List<Pet> pets = Pets.list(8);
LinkedList<Pet> petsLL = new LinkedList<>(pets);
HashSet<Pet> petsHS = new HashSet<>(pets);
TreeSet<Pet> petsTS = new TreeSet<>(pets);

View File

@ -1,5 +1,5 @@
// containers/EnvironmentVariables.java
// ©2016 MindView LLC: see Copyright.txt
// collections/EnvironmentVariables.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/ForInCollections.java
// ©2016 MindView LLC: see Copyright.txt
// collections/ForInCollections.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// All collections work with for-in.

View File

@ -1,5 +1,5 @@
// containers/GenericsAndUpcasting.java
// ©2016 MindView LLC: see Copyright.txt
// collections/GenericsAndUpcasting.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/InterfaceVsIterator.java
// ©2016 MindView LLC: see Copyright.txt
// collections/InterfaceVsIterator.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
@ -19,7 +19,7 @@ public class InterfaceVsIterator {
System.out.println();
}
public static void main(String[] args) {
List<Pet> petList = Pets.arrayList(8);
List<Pet> petList = Pets.list(8);
Set<Pet> petSet = new HashSet<>(petList);
Map<String, Pet> petMap = new LinkedHashMap<>();
String[] names = ("Ralph, Eric, Robin, Lacey, " +

View File

@ -1,5 +1,5 @@
// containers/IterableClass.java
// ©2016 MindView LLC: see Copyright.txt
// collections/IterableClass.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Anything Iterable works with for-in.

View File

@ -1,5 +1,5 @@
// containers/LinkedListFeatures.java
// ©2016 MindView LLC: see Copyright.txt
// collections/LinkedListFeatures.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
@ -8,7 +8,7 @@ import java.util.*;
public class LinkedListFeatures {
public static void main(String[] args) {
LinkedList<Pet> pets =
new LinkedList<>(Pets.arrayList(5));
new LinkedList<>(Pets.list(5));
System.out.println(pets);
// Identical:
System.out.println(
@ -27,9 +27,9 @@ public class LinkedListFeatures {
System.out.println(pets);
pets.addFirst(new Rat());
System.out.println("After addFirst(): " + pets);
pets.offer(Pets.randomPet());
pets.offer(Pets.get());
System.out.println("After offer(): " + pets);
pets.add(Pets.randomPet());
pets.add(Pets.get());
System.out.println("After add(): " + pets);
pets.addLast(new Hamster());
System.out.println("After addLast(): " + pets);

View File

@ -1,5 +1,5 @@
// containers/ListFeatures.java
// ©2016 MindView LLC: see Copyright.txt
// collections/ListFeatures.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
@ -8,7 +8,7 @@ import java.util.*;
public class ListFeatures {
public static void main(String[] args) {
Random rand = new Random(47);
List<Pet> pets = Pets.arrayList(7);
List<Pet> pets = Pets.list(7);
System.out.println("1: " + pets);
Hamster h = new Hamster();
pets.add(h); // Automatically resizes
@ -53,7 +53,7 @@ public class ListFeatures {
pets.clear(); // Remove all elements
System.out.println("19: " + pets);
System.out.println("20: " + pets.isEmpty());
pets.addAll(Pets.arrayList(4));
pets.addAll(Pets.list(4));
System.out.println("21: " + pets);
Object[] o = pets.toArray();
System.out.println("22: " + o[3]);

View File

@ -1,5 +1,5 @@
// containers/ListIteration.java
// ©2016 MindView LLC: see Copyright.txt
// collections/ListIteration.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
@ -7,7 +7,7 @@ import java.util.*;
public class ListIteration {
public static void main(String[] args) {
List<Pet> pets = Pets.arrayList(8);
List<Pet> pets = Pets.list(8);
ListIterator<Pet> it = pets.listIterator();
while(it.hasNext())
System.out.print(it.next() + ", " + it.nextIndex() +
@ -21,7 +21,7 @@ public class ListIteration {
it = pets.listIterator(3);
while(it.hasNext()) {
it.next();
it.set(Pets.randomPet());
it.set(Pets.get());
}
System.out.println(pets);
}

View File

@ -1,8 +1,8 @@
// containers/MapOfList.java
// ©2016 MindView LLC: see Copyright.txt
// collections/MapOfList.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package containers;
package collections;
import typeinfo.pets.*;
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/ModifyingArraysAsList.java
// ©2016 MindView LLC: see Copyright.txt
// collections/ModifyingArraysAsList.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/MultiIterableClass.java
// ©2016 MindView LLC: see Copyright.txt
// collections/MultiIterableClass.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Adding several Adapter Methods.
@ -7,24 +7,27 @@ import java.util.*;
public class MultiIterableClass extends IterableClass {
public Iterable<String> reversed() {
return () -> new Iterator<String>() {
int current = words.length - 1;
@Override
public boolean hasNext() { return current > -1; }
@Override
public String next() { return words[current--]; }
@Override
public void remove() { // Not implemented
throw new UnsupportedOperationException();
return new Iterable<String>() {
public Iterator<String> iterator() {
return new Iterator<String>() {
int current = words.length - 1;
public boolean hasNext() { return current > -1; }
public String next() { return words[current--]; }
public void remove() { // Not implemented
throw new UnsupportedOperationException();
}
};
}
};
}
public Iterable<String> randomized() {
return () -> {
List<String> shuffled =
new ArrayList<>(Arrays.asList(words));
Collections.shuffle(shuffled, new Random(47));
return shuffled.iterator();
return new Iterable<String>() {
public Iterator<String> iterator() {
List<String> shuffled =
new ArrayList<String>(Arrays.asList(words));
Collections.shuffle(shuffled, new Random(47));
return shuffled.iterator();
}
};
}
public static void main(String[] args) {

View File

@ -1,12 +1,12 @@
// containers/NonCollectionSequence.java
// ©2016 MindView LLC: see Copyright.txt
// collections/NonCollectionSequence.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
import java.util.*;
class PetSequence {
protected Pet[] pets = Pets.createArray(8);
protected Pet[] pets = Pets.array(8);
}
public class NonCollectionSequence extends PetSequence {

View File

@ -1,5 +1,5 @@
// containers/PetMap.java
// ©2016 MindView LLC: see Copyright.txt
// collections/PetMap.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;

View File

@ -1,11 +1,11 @@
// containers/PrintingContainers.java
// ©2016 MindView LLC: see Copyright.txt
// collections/PrintingCollections.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Containers print themselves automatically.
// Collections print themselves automatically.
import java.util.*;
public class PrintingContainers {
public class PrintingCollections {
static Collection fill(Collection<String> collection) {
collection.add("rat");
collection.add("cat");

View File

@ -1,5 +1,5 @@
// containers/PriorityQueueDemo.java
// ©2016 MindView LLC: see Copyright.txt
// collections/PriorityQueueDemo.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/QueueDemo.java
// ©2016 MindView LLC: see Copyright.txt
// collections/QueueDemo.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Upcasting to a Queue from a LinkedList.

View File

@ -1,5 +1,5 @@
// containers/SetOfInteger.java
// ©2016 MindView LLC: see Copyright.txt
// collections/SetOfInteger.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/SetOperations.java
// ©2016 MindView LLC: see Copyright.txt
// collections/SetOperations.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/SimpleCollection.java
// ©2016 MindView LLC: see Copyright.txt
// collections/SimpleCollection.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/SimpleIteration.java
// ©2016 MindView LLC: see Copyright.txt
// collections/SimpleIteration.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import typeinfo.pets.*;
@ -7,7 +7,7 @@ import java.util.*;
public class SimpleIteration {
public static void main(String[] args) {
List<Pet> pets = Pets.arrayList(12);
List<Pet> pets = Pets.list(12);
Iterator<Pet> it = pets.iterator();
while(it.hasNext()) {
Pet p = it.next();

View File

@ -1,5 +1,5 @@
// containers/SortedSetOfInteger.java
// ©2016 MindView LLC: see Copyright.txt
// collections/SortedSetOfInteger.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;

View File

@ -1,5 +1,5 @@
// containers/StackCollision.java
// ©2016 MindView LLC: see Copyright.txt
// collections/StackCollision.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.

View File

@ -1,5 +1,5 @@
// containers/StackTest.java
// ©2016 MindView LLC: see Copyright.txt
// collections/StackTest.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import onjava.*;

View File

@ -1,5 +1,5 @@
// containers/Statistics.java
// ©2016 MindView LLC: see Copyright.txt
// collections/Statistics.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Simple demonstration of HashMap.

View File

@ -1,5 +1,5 @@
// containers/UniqueWords.java
// ©2016 MindView LLC: see Copyright.txt
// collections/UniqueWords.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import java.util.*;
@ -20,7 +20,7 @@ public class UniqueWords {
/* Output:
[A, B, C, Collections, D, E, F, G, H, HashSet, I, J, K, L,
M, N, Output, Set, SetOperations, String, System, X, Y, Z,
add, addAll, added, args, class, containers, contains,
add, addAll, added, args, class, collections, contains,
containsAll, false, from, import, in, java, main, new, out,
println, public, remove, removeAll, removed, set1, set2,
split, static, to, true, util, void]

View File

@ -1,5 +1,5 @@
// containers/UniqueWordsAlphabetic.java
// ©2016 MindView LLC: see Copyright.txt
// collections/UniqueWordsAlphabetic.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Producing an alphabetic listing.
@ -20,10 +20,10 @@ public class UniqueWordsAlphabetic {
}
}
/* Output:
[A, add, addAll, added, args, B, C, class, Collections,
containers, contains, containsAll, D, E, F, false, from, G,
H, HashSet, I, import, in, J, java, K, L, M, main, N, new,
out, Output, println, public, remove, removeAll, removed,
Set, set1, set2, SetOperations, split, static, String,
System, to, true, util, void, X, Y, Z]
[A, add, addAll, added, args, B, C, class, collections,
contains, containsAll, D, E, F, false, from, G, H, HashSet,
I, import, in, J, java, K, L, M, main, N, new, out, Output,
println, public, remove, removeAll, removed, Set, set1,
set2, SetOperations, split, static, String, System, to,
true, util, void, X, Y, Z]
*/

View File

@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<project default="run">
<property name="chapter" value="containers"/>
<property name="chapter" value="collections"/>
<property name="excludedfiles" value=""/>
<import file="../Ant-Common.xml"/>
<import file="../Ant-Clean.xml"/>
@ -13,9 +13,9 @@
<jrun cls="ApplesAndOrangesWithoutGenerics" failOnError='false' msg='* Exception was Expected *' />
<jrun cls="ArrayIsNotIterable" />
<jrun cls="AsListInference" />
<jrun cls="CollectionMethods" />
<jrun cls="CollectionSequence" />
<jrun cls="ContainerMethods" />
<jrun cls="CrossContainerIteration" />
<jrun cls="CrossCollectionIteration" />
<jrun cls="EnvironmentVariables" />
<jrun cls="ForInCollections" />
<jrun cls="GenericsAndUpcasting" />
@ -24,12 +24,12 @@
<jrun cls="LinkedListFeatures" />
<jrun cls="ListFeatures" />
<jrun cls="ListIteration" />
<jrun cls="containers.MapOfList" dirpath="../containers" />
<jrun cls="collections.MapOfList" dirpath="../collections" />
<jrun cls="ModifyingArraysAsList" />
<jrun cls="MultiIterableClass" />
<jrun cls="NonCollectionSequence" />
<jrun cls="PetMap" />
<jrun cls="PrintingContainers" />
<jrun cls="PrintingCollections" />
<jrun cls="PriorityQueueDemo" />
<jrun cls="QueueDemo" />
<jrun cls="SetOfInteger" />

Some files were not shown because too many files have changed in this diff Show More