This method is used to compare the receiver object (this
)
with the argument object (arg0
) for equivalence
This method is used to compare the receiver object (this
)
with the argument object (arg0
) for equivalence.
The default implementations of this method is an equivalence relation:
x
of type Any
,
x.equals(x)
should return true
.x
and y
of type
Any
, x.equals(y)
should return true
if and only
if y.equals(x)
returns true
.x
, y
, and z
of type AnyRef
if x.equals(y)
returns true
and
y.equals(z)
returns
true
, then x.equals(z)
should return true
.
If you override this method, you should verify that
your implementation remains an equivalence relation.
Additionally, when overriding this method it is often necessary to
override hashCode
to ensure that objects that are
"equal" (o1.equals(o2)
returns true
)
hash to the same Int
(o1.hashCode.equals(o2.hashCode)
).
the object to compare against this object for equality.
true
if the receiver object is equivalent to the argument; false
otherwise.
Flush the output stream
Flush the output stream. This function is required when partial output (i.e. output not terminated by a new line character) has to be made visible on the terminal.
Returns a hash code value for the object
Returns a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash
codes (o1.hashCode.equals(o2.hashCode)
) yet not be
equal (o1.equals(o2)
returns false
). A
degenerate implementation could always return 0
.
However, it is required that if two objects are equal
(o1.equals(o2)
returns true
) that they
have identical hash codes
(o1.hashCode.equals(o2.hashCode)
). Therefore, when
overriding this method, be sure to verify that the behavior is
consistent with the equals
method.
Print an object on the terminal
Print an object on the terminal.
the object to print.
Prints its arguments as a formatted string, based on a string pattern (in a fashion similar to printf in C)
Prints its arguments as a formatted string, based on a string pattern (in a fashion similar to printf in C).
The interpretation of the formatting patterns is described in
java.util.Formatter
.
the pattern for formatting the arguments.
the arguments used to instantiating the pattern.
Print out an object followed by a new line character
Print out an object followed by a new line character.
the object to print.
Print a new line character on the terminal
Print a new line character on the terminal.
Read a boolean value from the terminal
Read a boolean value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Read a byte value from the terminal
Read a byte value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Read a char value from the terminal
Read a char value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Read a double value from the terminal
Read a double value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Read a float value from the terminal
Read a float value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Read an int value from the terminal
Read an int value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Print a formatted text and read a full line from the terminal
Print a formatted text and read a full line from the terminal. Returns null if the end of the input stream has been reached.
the format of the text to print out.
the parameters used to instantiate the format.
the string read from the terminal.
Read a full line from the terminal
Read a full line from the terminal. Returns null
if the end of the
input stream has been reached.
Read an int value from the terminal
Read an int value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Read a short value from the terminal
Read a short value from the terminal.
Throws EOFException
if the end of the
input stream has been reached.
Read in some structured input, specified by a format specifier
Read in some structured input, specified by a format specifier.
See class java.text.MessageFormat
for details of
the format specification.
Throws EOFException
if the end of the
input stream has been reached.
the format of the input.
a list of all extracted values.
Read in some structured input, specified by a format specifier
Read in some structured input, specified by a format specifier.
Opposed to readf
, this function only returns the
first value extracted from the input according to the format
specification.
...
...
Read in some structured input, specified by a format specifier
Read in some structured input, specified by a format specifier.
Opposed to readf
, this function only returns the
first two values extracted from the input according to the format
specification.
...
...
Read in some structured input, specified by a format specifier
Read in some structured input, specified by a format specifier.
Opposed to readf
, this function only returns the
first three values extracted from the input according to the format
specification.
...
...
Set the default error stream
Set the default error stream.
the new error stream.
Set the default error stream
Set the default error stream.
the new error stream.
Set the default input stream
Set the default input stream.
the new input stream.
Set the default input stream
Set the default input stream.
specifies the new input stream.
Set the default output stream
Set the default output stream.
Set the default output stream
Set the default output stream.
the new output stream.
Returns a string representation of the object
Returns a string representation of the object.
The default representation is platform dependent.
Set the default error stream for the duration of execution of one thunk
Set the default error stream for the duration of execution of one thunk.
the new error stream.
the code to execute with the new error stream active
...
Set the default error stream for the duration of execution of one thunk
Set the default error stream for the duration of execution of one thunk.
the new error stream.
the code to execute with the new error stream active
...
Set the default input stream for the duration of execution of one thunk
Set the default input stream for the duration of execution of one thunk.
the new input stream.
the code to execute with the new input stream active
Set the default input stream for the duration of execution of one thunk
Set the default input stream for the duration of execution of one thunk.
the code to execute with the new input stream active
Set the default output stream for the duration of execution of one thunk
Set the default output stream for the duration of execution of one thunk.
the new output stream.
the code to execute with the new output stream active
...
Set the default output stream for the duration of execution of one thunk
Set the default output stream for the duration of execution of one thunk.
the new output stream.
the code to execute with the new output stream active
...
The
Console
object implements functionality for printing Scala values on the terminal. There are also functions for reading specific values.Console
also defines constants for marking up text on ANSI terminals.