Professional Documents
Culture Documents
(Part II)
SQL STAR INTERNATIONAL
June, 2009
-- 3.3 --
Passing
Variables into
Methods
7.3 Determine the effect upon object references and primitive values when
they are passed into methods that perform assignments or other modifying
operations on the parameters.
Java: pass-by-copy-of-the-variable (1)
• can take primitives and/or object references
• Java: pass-by-copy-of-the-variable
• always passing a copy of the bits in the variable
• method can't change the caller's variable,
• Passing Object Reference Variables:
• keep in mind that you're passing the object reference, and not
the actual object itself
• aren't even passing the actual reference variable, but rather a
copy of the reference variable
• two identical reference variables refer to the exact same object
• can't reassign the caller's original reference variable and make it
refer to a different object, or null
• Passing Primitive Variables
• Only a copy, so won’t change the value of the primitive
3
++ Shadowed variables
• Shadowing involves re-declaring a variable
that's already been declared somewhere else
• shadow an instance variable by declaring a local
variable of the same name
• Shadow a reference variable should keep in your mind
with: can change the object value, but can’t assign to
another object.
• It is very easy to be a test
4
Array
1.3 Develop code that declares, initializes, and uses primitives, arrays,
enums, and objects as static, instance, and local variables. Also, use legal
identifiers for variable names.
Basic concepts
• Arrays are objects in Java that store multiple
variables of the same type
• An array of objects can hold any object that passes
the IS-A (or instanceof) test for the declared type of
the array;
• can hold either primitives or object references
• always be an object on the heap
• ## For exam ##
• How to make an array reference variable (declare)
• How to make an array object (construct)
• How to populate the array with elements (initialize)
6
Declarations
• Declaring an Array of Primitives
• int[] key; // Square brackets before name (recommended)
• int key []; // Square brackets after name (legal but less
readable)
• Declaring an Array of Object References
• Thread[] threads; // Recommended
• Thread threads []; // Legal but less readable
• multidimensional arrays:
• String[][] occupantName;
• String[] ManagerName []; // it's legal doesn't mean it's right
• illegal to include the size of the array in your
declaration:
• int [5] scores; is not right
7
Constructing
• To create an array object, Java must know how much space to allocate
on the heap, so you must specify the size of the array at creation time.
• must have either a dimension expression or an initializer. If fail to do,
then a compile-time error is generated.
• int scores[ ] = new int[5];
• int[ ] scores = new int[ ] {1,2,3,4,5} ;
• One-Dimensional Arrays
• Multidimensional Arrays
• an object of type int array (int[]), with each element in that array holding
a reference to another int array.
• The second dimension holds the actual int primitives.
• Must specify the first dimension, can not only define the second
without define the first
• ++ int [ ] [ ] x = new int [5] [ ] is legal new int [ ] [5] is illegal
• the JVM needs to know only the size of the object assigned to the
variable myArray.
• ++ WRONG: int [ ] x = new short [ ]; short can put into int[ ], but
char [ ] can not assign to int[ ].
• ++ CANNOT define both size and initialize at the same time
8
Initialization
• Array doesn't actually hold the objects, but instead
holds a reference to the object.
• ++ Array index number always begins with zero
• Need to assign elements to reference the actual
created objects one by one.
• Try to use null element will get an NullPointerException
• out-of-range array index will get an
ArrayIndexOutOfBoundsException
• Declaring, Constructing, and Initializing on One Line
• for(Dog d : myDogs) d = new Dog();
• Constructing and Initializing an Anonymous Array
• Init blocks execute in the order they appear.
• Static init blocks run once, when the class is first loaded.
• Instance init blocks run every time a class instance is created.
• Instance init blocks run after the constructor's call to super().
9
++ Initialization Blocks
• ++ Instance init blocks are often used as a
place to put code that all the constructors
in a class should share. That way, the code
doesn't have to be duplicated across
constructors.
2. static blocks run only once, when the class
is first loaded
• any mistake in static blocks, JVM throw
ExceptionInInitializationError
3. Initial blocks execute in the order of they
appear, after call new
• Initial blocks can be repeatedly run depend on the
objects creation
10
-- 3.5 --
Using Wrapper
Classes and
Boxing
3.1 Develop code that uses the primitive wrapper classes (such as
Boolean, Character, Double, Integer, etc.), and/or autoboxing & unboxing.
Discuss the differences between the String, StringBuilder, and
StringBuffer classes.
Overview
• boolean | Boolean | boolean or String
• byte | Byte | byte or String
• char | Character | char
• double | Double | double or String
• float | Float | float, double, or String
• short | Short | short or String
• int | Integer | int or String
• long | Long | long or String
19
Explicit Code Makes Objects
Eligible for Collection
• Nulling a Reference
• Reassigning a Reference Variable
• Isolating a Reference
• instance variables so that they refer to each other, but their links
to the outside world have been nulled.
• Forcing Garbage Collection
• The garbage collection routines that Java provides are members
of the Runtime class.
• The Runtime class is a special class that has a single object (a
Singleton) for each main program.
• Runtime.getRuntime(): returns the Singleton
• Once you have the Singleton you can invoke the garbage
collector using the gc() method;
• Runtime.getRuntime().gc();
or
• System.gc();
20
finalize()
• every class inherits the finalize() method from java.lang.Object
• finalize () is called by the garbage collector when it
determines no more references to the object exist
• Cleaning up before Garbage Collection—The finalize() Method
• For any given object, finalize () will be called only once (at most) by the
garbage collector.
• Calling finalize() can actually result in saving an object from deletion.
• CAN be overridden
• normally it should be overridden to clean-up non-Java resources ie
closing a file
• use a try-catch-finally statement and to always call super.finalize()
23
Assignment Operators
(=)
• When assigning a value to a primitive, size matters.
Be sure you know when implicit casting will occur,
when explicit casting is necessary, and when
truncation might occur.
• Remember that a reference variable isn't an object;
it's a way to get to an object.
• When assigning a value to a reference variable, type
matters. Remember the rules for supertypes,
subtypes, and arrays
• Super ref = sub object, is wrong
• Sub ref = super object, is ok
• Instance methods depend on real object
• Static method, static variable depend on reference 24
"Equality" Operators
(== , !=)
• Four testable types of things:
• numbers
• characters
• boolean primitives
• Object reference variables
• When == is used to compare a primitive to a wrapper object, the
wrapper object will be unwrapped to its primitive value, and the
comparison will be made between the two primitives' values
• Only for those Wrappers: Boolean, Byte, Character from \u0000 to
\u007f , Integer, Short
• Equality for Primitives
• Equality for Reference Variables
• Equality for Enums
• instanceof Comparison: should pass IS-A test
• Legal to test whether the null reference is an instance of a class. will
always result in false
• can't use the instanceof operator to test across two different class
hierarchies 25
Logical Operators
• Bitwise Operators (&, |, and ^)
• Short-Circuit Logical Operators ( &&, || )
• work only with boolean operands.
• Logical Operators (&, |, ^ and ! )
• evaluate both sides of the expression, always
26
++ instanceof
• Returns true if the reference variable being tested is
of the type being compared to
• if (t1 instanceof Object) {
• System.out.println(“ t1 is an Object.");
• } else {
• System.out.println(“ t1 isn’t an Object.");
• }
• ++ null instanceof Xxx always be false
• ++ instanceof can not test two different class
hierarchies, will cause compile error
• ++ Trick:
• Integer [] x x instanceof Object true, not
Integer yet
• Integer[1] instanceof Object and Integer, Number
are true
27
Other operators
• Compound Assignment Operators ( +=, -=, *=, and /= )
• ++ x *= 2 + 5; x = x * (2 + 5) ;
• the expression on the right is always placed inside parentheses
• Relational Operators ( <, <= , >, >=, == , and != )
• Arithmetic Operators( +, -, *, /, % )
• String Concatenation Operator
• If either operand is a String, the + operator becomes a String
concatenation operator. If both operands are numbers, the +
operator is the addition operator.
• Increment and Decrement Operators (++, - -)
• ++ Conditional Operator:
• X = (boolean expression) ? value to assign if true : value to
assign if false;
28
-- 5.1 --
Flow Control
if and switch Statements
30
switch
• switch (expression) { }
• ++ only accept: variables and values that can be
automatically promoted to an int
• Can use an enum
• Case constant:
• Case variable must be constant
• must evaluate to the same type as the switch expression
• ++ Byte expression case 128 is out of range
• ++ final int a = 1; is a constant, compile time constant
• ++ final int b; b= 1; not a constant
33
for
• for (/*Initialization*/ ; /*Condition*/ ; /* Iteration */) {
• /* loop body */
• }
• None of the three sections of the for declaration are required for( ; ; ) {}
• Initialization expression :
• Can declare more than one, Separate with comma
• ++ Be careful the scope problem: for(int x; ;) can not use x out of for
loop
• ++ int x = 0; for(; x<10;) { x++ } is legal and x can be used out of for loop
• Conditional expression
• Only one test expression
• Interation Expression
• After the body run finished
• ++ break, return, System.exit() will cause a loop terminate
35
++ Special controls
• continue
• statements must be inside a loop
• break
• statements must be used inside either a loop or switch
statement
• Execution jumps immediately to the 1st statement after
the for loop.
• return
• Execution jumps immediately back to the calling
method.
• system.exit()
• All program execution stops; the VM shuts down.
36
Labeled Statements
• most common to use labels with loop statements
like for or while, in conjunction with break and
continue statements.
• Not for if statement
• A label statement
• ++ must be placed just before the statement
• being labeled plus a “:”
• Labeled continue and break statements must be
inside the loop that has the same label name;
otherwise, the code will not compile.
37
-- 5.4 --
Handling
Exceptions
2.4 Develop code that makes use of exceptions and exception
handling clauses (try, catch, finally), and declares methods and
overriding methods that throw exceptions.
2.5 Recognize the effect of an exception arising at a specific point
in a code fragment, Note that the exception may he a runtime
exception, a checked exception, or an error.
try and catch/finally
• try is used to define guarded region, a block of code in which
exceptions may occur
• Must be followed by either catch or finally, or both
• Can't sneak any code in between the try, catch, or finally blocks.
• only with finally, must still declare the exception
• catch clauses match a specific exception to a block of code
that handles it
• no requirement that catch clause for every possible exception
• The order of catch must from smaller to bigger (exception hierarchy )
• finally block encloses code that is always executed at some
point after the try block, whether an exception was thrown or
not.
• ++ Even if there is a return statement in the try block, the finally block
executes right after the return statement is encountered, and before the
return executes
• If the try block executes with no exceptions, the finally block is executed
immediately after the try block completes.
• Is not required 39
Exception propagation “duck”
• ++ Rule: “handle or declare”
• Can throws the exception down to the bottom of
stack
• the exception drops down to the previous method,
until it is caught or until it reaches the very bottom
of the call stack.
• An exception that's never caught will cause your
application to stop running.
• main() need to handle the exception, otherwise JVM will shut
down
40
Checked/Runtime exception
• Throws & throw:
• void xxxx() throws xxException {
• If (condition== ture) {
• throw new xxException();
• }
• }
• Checked exception:
• Compiler guarantees the exceptions have been checked
• Each method must either handle all checked exceptions by
supplying a catch clause or list each unhandled checked
exception as a thrown exception. (declare/ duck)
• Runtime (Unchecked) exception:
• Compiler won’t check it
• Can wrap it by try/catch, or leave it be
41
Multiple Throw/Catch
Multiple Throw
• A method can throw multiple exceptions
• void xxxMethod() throws xxException, yyException { }
Multiple Catch
• try { // some code }
• catch (Exception e) { e.printStackTrace(); }
• This code will catch every exception generated.
• No single exception handler can properly handle every exception, and
programming in this way defeats the design objective.
• ++ Catch the subclass then catch the superclass, otherwise get
compiler error:
• TestEx.java:15: exception java.io.FileNotFoundException has already been
caught
• } catch (FileNotFoundException ex) {
Re-throwing the Same Exception
• ++ Must handle and declare
• declare that exception
• Catch throw the same exception you just caught
• Catch (IOException e) { throw e; }
• All other catch clauses are ignored
42
43
Exception hierarchy
• Throwable classes, includes Exception and Error.
• exceptions are always some subclass of java.lang.Exception
• Exception, Error, RuntimeException, and Throwable types
can all be thrown using the throw keyword, and can all be
caught
• Two methods in Throwable:
• getMessage()
• printStackTrace()
• Create your own exception
• class MyException extends Exception { }
• ++ Override method
• It's okay for an overriding method to throw the same
exceptions, narrower exceptions, or no exceptions.
• it's okay for the overriding method to throw any runtime
exceptions.
44
Error
• Objects of type Error are not Exception
objects, although they do represent
exceptional conditions.
• ++ Also use throw keyword
• Error is unchecked
• You are not required to catch Error objects or
Error subtypes. You can do it
• No need to declare an Error
45
-- 5.5 --
Common
Exceptions
& Errors
2.6 Understand which of these are thrown by the virtual
machine and recognize situations in which others should be
thrown programmatically
Categories of Exceptions/Errors
• JVM exceptions Those exceptions or errors that are either
exclusively or most logically thrown by the JVM.
• There's no way that the compiler can hope to find these
problems before runtime.
• Programmatic exceptions Those exceptions that are thrown
explicitly by application and/or API programmers.
• Do not depend on the RuntimeException
• ++ 2.6 Recognize situations that will result in any of the
following being thrown:
• AssertionError, ExceptionInInitializerError,
• StackOverflowError, NoClassDefFoundError,
• ClassCastException, ArrayIndexOutOfBoundsException,
• IllegalArgumentException, NumberFormatException,
• IllegalStateException, NullPointerException.
• ++ Understand which of these are thrown by the virtual
machine and recognize situations in which others should be
thrown programmatically.
47
Distinguish
• Checked exceptions
• ++ are subclass's of Exception excluding class RuntimeException and
its subclasses.
• Checked Exceptions forces programmers to deal with the exception that
may be thrown.
• Example: Arithmetic exception. When a checked exception occurs in a
method, the method must either catch the exception and take the
appropriate action, or pass the exception on to its caller
• Unchecked exceptions
• are RuntimeException and any of its subclasses. Class Error and its
subclasses also are unchecked.
• Unchecked exceptions , however, the compiler doesn't force the
programmers to either catch the exception or declare it in a throws
clause.
• In fact, the programmers may not even know that the exception could be
thrown. Example: ArrayIndexOutOfBounds Exception.
• They are either irrecoverable (Errors) and the program should not
attempt to deal with them, or they are logical programming errors.
(Runtime Exceptions).
• Checked exceptions must be caught at compile time. Runtime
exceptions do not need to be. Errors often cannot be. 48
Throwable inheritance tree
Object
|
|--> Throwable
|
|----> Error (Unchecked Exceptions)
| |
| |---> All other errors (Thrown by JVM)
|
|
|----> Exception
|
|--> RuntimeException (Unchecked Exception)
| |
| |---> All other exceptions (Thrown by jVM)
|
|--> All other exceptions (Unchecked Exception)
(Thrown programmatic or by API's programmer)
49
Common Errors
• StackOverflowError – Error - JVM Thrown -UN
• Thrown when a stack overflow occurs because an application
recurses too deeply.
• The most common way for this to occur is to create a recursive
method. A recursive method is one that invokes itself in the method
body.
• runs out of space to store the call stack.
• NoClassDefFoundError – Error - JVM Thrown -UN
• Thrown when the JVM can't find a class it needs, because of a
command-line error, a classpath issue, or a missing .class file.
• AssertionError - Error – Programmatic -UN
• Thrown when a statement's boolean test returns false.
• The seven one-argument public constructors provided by this class
ensure that the assertion error returned by the invocation.
• ExceptionInInitializerError - Error - JVM Thrown -UN
• Thrown when attempting to initialize a static variable or an
initialization block.
• Signals that an unexpected exception has occurred in a static initializer.
An ExceptionInInitializerError is thrown to indicate that an exception
occurred during evaluation of a static initializer or the initializer for a 50
static variable.
Common Exceptions (1)
• ArithmeticException - RuntimeException -UN
• Thrown when an exceptional arithmetic condition has occurred.
• For example, an integer "divide by zero" throws an instance of this
class.
• ++ NullPointerException() - RuntimeException - JVM Thrown -UN
• Thrown when you attempt to access an object using a reference
variable with a current value of null.
• There's no way that the compiler can hope to find these problems before
runtime.
• Calling the instance method of a null object.
• Accessing or modifying the field of a null object.
• Taking the length of null as if it were an array.
• Accessing or modifying the slots of null as if it were an array.
• Throwing null as if it were a Throwable value.
• Applications should throw instances of this class to indicate other
illegal uses of the null object.
• ClassCastException - RuntimeException - JVM Thrown - UN
• Thrown when attempting to cast a reference variable to a type that
fails the IS-A test.
51
Common Exceptions (2)
• IllegalArgumentException - RuntimeException – Programmatic -UN
• Thrown to indicate that a method has been passed an illegal or
inappropriate argument.
• NumberFormatException -RuntimeException – Programmatic -UN
• ++ subclass of IllegalArgumentException
• Thrown to indicate that the application has attempted to convert a string
to one of the numeric types, but that the string does not have the
appropriate format.
• IllegalStateException - RuntimeException – Programmatic -UN
• Signals that a method has been invoked at an illegal or inappropriate
time.
• The Java environment or Java application is not in an appropriate state
for the requested operation.
• e.g., using a Scanner that's been closed.
• ArrayIndexOutOfBoundsException - RuntimeException - JVM Thrown
-UN
• Thrown to indicate that an array has been accessed with an illegal
index. The index is either negative or greater than or equal to the size of
the array.
52
-- 5.6 --
Assertion
Mechanism
56
Strings
58
Important Methods in the String Class
(1)
• public char charAt(int index) Returns the character
located at the specified index
• public String concat(String s) Appends one String to
the end of another (overloaded + and += operators also
works)
• public boolean equalslgnoreCase(String s)
Determines the equality of two Strings, ignoring case
• public int length() Returns the number of characters in
a String
• Distinguish from array’s attribute: Array.length;
• public String replace(char old, char new) Replaces
occurrences of a character with a new character
• public String Substring(int Begin)
• public String substring(int begin, int end) Returns a 59
part of a String (cut end-1)
Important Methods in the String Class
(2)
• public String toLowerCase() Returns a String with
uppercase characters converted
• public String toString() Returns the value of a String
• public String toUpperCase() Returns a String with
lowercase characters converted
• public String trim() Removes whitespace from the ends
of a String
• public int IndexOf(int ch, int fromIndex) Returns the
index within this string of the first occurrence of the
specified substring.
• public int lastIndexOf(int ch, int fromIndex) Returns
the index within this string of the last occurrence of
the specified character, searching backward starting
at the specified index.
• public boolean startsWith (String prefix) 60
• public boolean endsWith (String prefix)
StringBuffer and StringBuilder Classes
• Should be used when you have to make a lot of
modifications to strings of characters
• A common use for StringBuffers and StringBuilders
is file I/O when large, ever-changing streams of input
are being handled by the program.
• In these cases, large blocks of characters are handled as units,
and StringBuffer objects are the ideal way to handle a block of
data, pass it on, and then reuse the same memory to handle the
next block of data.
• StringBuffer vs. StringBuilder
• StringBuilder class was added in Java 5.
• StringBuilder has exactly the same API as the StringBuffer class,
• StringBuilder is not thread safe (methods are not synchronized )
• StringBuilder will run faster
• Method calls can be chained to each other
61
Important Methods in StringBuffer &
StringBuilder
• StringBuffer objects and StringBuilder objects can be changed.
• public synchronized StringBuffer append(String s)
• public StringBuilder delete(int start, int end) a substring is removed from
the original object. (as same as substring)
• public StringBuilder insert(int offset, String s) insert s into the original
StringBuilder starting at the offset location
• public synchronized StringBuffer reverse()
• public String toString()
• chained methods
• Determine what the leftmost method call will return (let's call it x).
• Use x as the object invoking the second (from the left) method. If
there are only two chained methods, the result of the second
method call is the expression's result.
• If there is a third method, the result of the second method call is
used to Invoke the third method, whose result is the expression's
result
62
++ Exam watch
• ++ Be careful: String has no insert(), append(), delete(),
reverse()
• ++ String always need assign the result to the reference, but
StringBiffer/StringBuilder needn’t
• s.concat(“xx”); will be lost if there is not: s = s.concat(“xx”);
• ++ String s = “xx”; is not String x = new String(“xx”); the new
keyword will create a normal object, not put the string into the
constant pool;
• String s = “xx”;
• String s1 = “xx”; s1== s is true
• String s2 = new String(“xx”); s2 ==s is false
• ++ the array has attribute length, String has method length();
• StringBuffer/StringBuilder do not have equals(), their equals()
means ==
63
-- 6.1 --
File Navigation
and I/O
3.2 Given a scenario involving navigating file systems, reading
from files, or writing to files, develop the correct solution using
the following classes (sometimes in combination), from java.io:
BufferedReader, BufferedWriter, File, FileReader, FileWriter, and
PrintWriter.
File I/O
• Always need import java.io.*;
• All the I/O stuff must be in a try/catch. Every
thing can throw an IOException.
• Don’t forget close();
• Chain BufferedWriter/ BufferedReader and
FileWriter/FileReader for efficiency.
• File object is not actual content of the file.
• Use split() to split a String into individual
tokens
65
I/O classes summary (1)
• File
• The API says that the class File is "An abstract
representation of file and directory pathnames."
• lets you manage (add, rename, and delete) files and
directories
• FileReader
• used to read character files. Its read() methods are
fairly low-level, allowing you to read single characters,
the whole stream of characters, or a fixed number of
characters.
• usually wrapped by higher-level objects such as
BufferedReaders, which improve performance and
provide more convenient ways to work with the data. 66
I/O classes summary (2)
• BufferedReader
• used to make lower-level Reader classes like FileReader more
efficient and easier to use.
• Compared to FileReaders, BufferedReaders read relatively large
chunks of data from a file at once, and keep this data in a buffer.
When you ask for the next character or line of data, it is retrieved
from the buffer, which minimizes the number of times that time-
intensive, file read operations are performed.
• In addition, BufferedReader provides more convenient methods
such as readLine(), that allow you to get the next line of
characters from a file.
• File Writer
• used to write to character files.
• Its write() methods allow you to write character(s) or Strings to a
file.
• FileWriters are usually wrapped by higher-level Writer objects
such as BufferedWriters or PrintWriters, which provide better
performance and higher-level, more flexible methods to write
data. 67
I/O classes summary (3)
• BufferedWriter
• used to make lower-level classes like FileWriters more efficient
and easier to use.
• Compared to FileWriters, BufferedWriters write relatively large
chunks of data to a file at once, minimizing the number of times
that slow, file writing operations are performed.
• In addition, the BufferedWriter class provides a newLine()
method that makes it easy to create platform-specific line
separators automatically.
• PrintWriter
• has been enhanced significantly in Java 5. Because of newly
created methods and constructors (like building a PrintWriter
with a File or a String), you might find that you can use
PrintWriter in places where you previously needed a Writer to be
wrapped with a FileWriter and/or a BufferedWriter.
• New methods like format(),printf(), and append() make
PrintWriters very flexible and powerful.
68
Write/Read a file
• createNewFile() and mkDir() add entries to your file
system.
• File f = new File (“xxxx.txt”);
• File dir = new File (“xxxxdir”);
• dir.mkdir();
• File myFile = new File(dir, "xxxx.txt ");
• myFile.createNewFile();
• BufferedWriter writer = new BufferedWriter(new
FileWriter(myFile ));
• Writer.close();
•
71
java.io.FileReader
• throws IOException
• throws FileNotFoundException
• java.lang.Object
java.io.Reader
java.io.InputStreamReader
java.io.FileReader
• java.lang.Object
java.io.Reader
java.io.BufferedReader
72
java.io.FileWriter
• throws IOException
• java.lang.Object
java.io.Writer
java.io.OutputStreamWriter
java.io.FileWriter
• java.lang.Object
java.io.Writer
java.io.BufferedWriter
• java.lang.Object
java.io.Writer
java.io.PrintWriter
73
FilenameFilter
• + java.io.FilenameFilter is an interface
which has one method:
• boolean accept(File dir, String name)
• can pass FilenameFilter to File's list() or
listFiles()
• File xxxdir = new File(“folder”);
• String[] a = xxxdir.list();
• File[] b = xxxdir.listFile();
• list() --> String[], including direction and files
• listFiles() --> File[]
74
Console (1)
• java.lang.Object
java.io.Console
• Make easy to accept input from and output to
command line
• import java.io.Console;
• Console c = System.console();
• String readLine()
• char[] readPassword(): for security purpose
75
Console (2)
• All the methods are:
• Void flush()
• Console format(String fmt, Object... args)
• Console printf (String fmt, Object... args):
• Reader reader()
• Retrieves the unique Reader object associated with this console.
• PrintWriter writer():
• Retrieves the unique PrintWriter object associated with this console.
• String readLine()
• String readLine(String fmt, Object... args):
• char[] readPassword()
• char[] readPassword(String fmt, Object... args)
• Reads a password or passphrase from the console with echoing
disabled
76