/**
* Copyright (C) 2022 by Martin Robillard. See https://codesample.info/about.html
*/
package e2.chapter8;
/**
* Sample observer of ObservableCardStack. Detects when an ace is pushed onto
* the stack. Two of the callbacks are unnecessary and purposefully not
* overridden.
*/
public class AceDetector implements CardStackObserver {
@Override
public void pushed(Card pCard) {
if (pCard.getRank() == Rank.ACE) {
System.out.println("Ace detected!");
}
}
}
Chapter 8, insight #11
If it is often the case that observers implement callbacks by doing nothing, consider using adapter classes or default methods
Chapter 8, insight #11
If it is often the case that observers implement callbacks by doing nothing, consider using adapter classes or default methods
System
class contains several useful class fields and methods. It cannot be instantiated. Among the facilities provided by the System
class are standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.
System
class contains several useful class fields and methods. It cannot be instantiated. Among the facilities provided by the System
class are standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.
Console.charset()
if the Console
exists, stdout.encoding otherwise.
Console.charset()
if the Console
exists, stdout.encoding otherwise.
For simple stand-alone Java applications, a typical way to write a line of output data is:
System.out.println(data)
See the println
methods in class PrintStream
.
print(String)
and then println()
.
print(String)
and then println()
.
x
- The String
to be printed.