|
Java
An Introduction for Programmers |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
// and the end of the line
is a comment/* and a */
is a comment
| Type | Memory | Range |
byte
|
1 byte | -128 to 127 |
short
|
2 bytes | -32,768 to 32,767 |
int
|
4 bytes | -2,147,483,648 to 2,147,483,647 |
float
|
4 bytes | |
double
|
8 bytes | |
char
|
2-4 bytes | Unicode |
boolean
|
true or false |
int[] income;
income = new int[20];
income[5] = 250000;
Arrays Utility Class
The Arrays class (in the java.util package)
contains several static methods that are very convenient when
working with arrays.
.java appended)public
public:
protected:
private:
public static double circleArea(double diameter)
public void update()
static
enums:
extends in the declaration of the classsuper as the left-side operand of the
. operatorsuper() (which must be in the
first statement in a constructor of the subclass)
final
can't be overridden by a subclassfinal
can't be specialized (i.e., a class that extends
a final class will not compile)
public class Identified<T>
extends,
followed by the bounding typeextends was probably a bad choice
since any class that either extends the bounding type or
implements the bounding type can be used