Java Reference
In-Depth Information
33
.
The operator
+
can be used to concatenate two strings.
34
.
During program execution, the contents of a named constant cannot be
changed.
35
.
A named constant is declared by using the reserved word
final
.
36
.
A named constant is initialized when it is declared.
37
.
All variables must be declared before they can be used.
38
.
Java may not automatically initialize all the variables you declare.
39
.
Every variable has a name, a value, a data type, and a size.
40
.
When a new value is assigned to a variable, the old value is overwritten.
41
.
Only an assignment statement or an input (read) statement can change the
value of a variable.
42
.
Input from the standard input device is accomplished by using a
Scanner
object initialized to the standard input device.
43
.
If
console
is a
Scanner
object initialized to the standard input device,
then the expression
console.nextInt()
retrieves the next integer from the
standard input device. Similarly, the expression
console.nextDouble()
retrieves the next floating number, and the expression
console.next()
retrieves the next string from the standard input device.
44
.
When data is input in a program, the data items, such as numbers, are
usually separated by blanks, lines, or tabs.
45
.
The increment operator,
++
, increases the value of its operand by 1.
46
.
The decrement operator,
--
, decreases the value of its operand by 1.
47
.
Output of the program to the standard output device is accomplished by
using the standard output object
System.out
and the methods
print
and
println
.
48
.
The character
\
is called the escape character.
49
.
The sequence
\n
is called the newline escape sequence.
50
.
A package is a collection of related classes. A class consists of methods, and a
method is designed to accomplish a specific task.
51
.
The
import
statement is used to import the components of a package into
a program. For example, the statement:
import
java.util.*;
imports the (components of the)
package
java.util
into the program.
52
.
In Java,
import
is a reserved word.
53
.
Because the primitive data types are directly part of the Java language, they
do not require any import statement to use them.
54
.
The
class
String
is contained in the package
java.lang
. You do not
need to import classes from the package
java.lang
. The system auto-
matically does it for you.
Search WWH ::
Custom Search