|
.toUpperCase()
|
.equals(str)
|
|
.toLowerCase()
|
.indexOf(e)
|
|
.substring(i,j) j is excluded
|
.concat(str)
|
|
.length()
|
.charAt(i)
|
|
.compareTo(str)
|
.contains(e)
|
|
Integer.parseInteger(intString)
|
|
|
Double.parseDouble(doubleString)
|
|
|
keywords
|
lowercase
|
rule
|
|
variables
|
camelCase
|
convention
|
|
constants
|
ALL_CAPS
|
rule
|
|
class names
|
CamelCase
|
convention
|
|
Math.pow(a, b)
|
Math.PI()
|
|
Math.log(x), Math.log10(x)
|
Math.sqrt(x)
|
|
Math.floor rounds down
|
Math.ceil() rounds up
|
|
Math.random()
|
Math.min(), Math.max()
|
|
\t
|
tab
|
|
\n
|
newline
|
|
\"
|
double quote
|
|
\\
|
backslash
|
|
jav.util.Date date= new java.util.Date;
|
|
date.toString();
|
|
import java.geometry.Point2D;
|
|
Point2D variable = new Point2D(x, y);
|
|
no variable constructor
|
Circle() {
} |
|
constructor
|
Circle (double radius) {
this.radius=radius;} |
|
getter
|
double getArea() {
return 2 x radius x radius x Math.PI; } |
|
setter
|
void setRadius(double radius) {
this.radius=radius;} |
|
instanceof
|
tests whether an object is an instance of a class
|
|
super();
|
calls no arg constructor of superclass
|
|
super(arg);
|
calls matching arg constructor of superclass
|
|
array of objects
|
for (int i, i<thing.length, i++)
array[i]= new Thing(param);} |
|
Abstract Classes
|
Interfaces
|
|
cannot use "new"
|
only has abstract methods
|
|
methods have no body
|
no constructors
|
|
mix of abstract/non-abstract methods
|
"implements"
|
|
"extends"
|
contains constants
|
|
has constructors
|
|
|
contains contacts and variables
|
|
|
while
|
int x=n;
while (x>1) { change x; } |
|
for
|
for (int i, i<variable, i++){
|
|
for each (arrays)
|
for (int i: list){
|
|
boolean
|
(boolean ? true : false)
|
|
.isDigit(ch)
|
.isLetter(ch)
|
|
.isLowerCase(ch), .isUpperCase(ch)
|
.toLowerCase(ch), .toUppercase(ch)
|
|
create
|
ArrayList<type> name = new ArrayList<type>();
|
|
access element
|
list.get(i)
|
|
update element
|
list.set(i, e)
|
|
return size
|
list.size()
|
|
add element
|
list.add((i), e)
|
|
remove element
|
list.remove(i or e)
|
|
remove all elements
|
list.clear()
|
|
modifier returnValueType methodName(params){
|
|
public Class ClassName{
public static void main (String[] args) |
|
Scanner input= new Scanner(System.in)
|
|
System.out.println(line);
|
|
public static type name (type param){
return type; } |
|
public boolean equals (Object o){
if (o instance Person){ Person p= (Person) o; return this.name.equals(p.getName())); }else{ return false; } } |
|
public String toString(){
return "String";} |
|
java.util.Arrays.sort(array)
|
.length
|
|
java.util.Arrays.equal(a1, a2)
|
if corresponding elements are the same
|
|
Arrays.toString(array)
|
.reverse()
|
|
array[i]
|
array[i]=e
|
elementType [rows][columns] arrayVar
|
composition
|
information belongs to one object
|
|
association/segregation
|
information can belong to many objects
|
|
public visibility
|
can be seen anywhere in any package
|
|
private visibility
|
can be seen within class
|
|
protected visibility
|
in package and subclasses of this in any package
|
|
runtime error
|
crash
|
|
compile error
|
doesn't run
|
|
final static
|
constant modifier
|
|
byte
|
8 bits*
|
|
block comment
|
/* ... */
|
|
line comment
|
//
|
|
javadoc comments
|
/** ... */
|
|
break;
|
breaks out of a loop
|
|
continue;
|
stays in loop
|
|
variable declaration
|
creating a variable with its type
|
|
static
|
shared by all instances of a class
|
|
relational operator
|
<, <=, ==, !=, >, >=
|
|
logical operator
|
!, &&, || (inclusive), ^ (exclusive)
|
|
Numeric Types (in order)
|
byte, short, int, long, float, double
|
|
Variable Scope
|
variables only exist within {}
|
|
assignment operators
|
=, +=, -=, *=, /=, %=
|
|
operators
|
+, -, %, / (truncates for int)
|
|
increment/ decrement operators
|
++, --
|
|
instance method
|
a method that can only be invoked from a specific object
|
|
local variable
|
within a method
|
|
instance variable
|
dependent on the specific instance (class)
|
|
overloading methods
|
methods can have the same name as long as their method signatures are different
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.