Java Midterm Cheat Sheet: by Via
Java Midterm Cheat Sheet: by Via
java.lang.Cloneable
has sin, cos, tan, toRadians, toDegree, asin,
public interface clonable {}
acos, atan
use .clone()
.isLowerCase(ch), .toLowerCase(ch), java.util.Arrays.equal(a1, a2) if relational <, <=, ==, !=, >, >=
.isUpperCase(ch) .toUppercase(ch) corresponding operator
elements are
logical !, &&, || (inclusive), ^
ArrayList Methods the same
operator (exclusive)
Arrays.toString(array) .reverse()
create ArrayList<type> name = new Numeric byte, short, int, long, float,
ArrayList<type>(); array[i] array[i]=e Types (in double
order)
access list.get(i) import java.util.Arrays;
element int[] values= new int[10] Variable variables only exist within {}
default values: 0, /u0000, or false Scope
update list.set(i, e)
element printing gives reference assignment =, +=, -=, *=, /=, %=
methods can modify arrays operators
return size list.size()
import java.util.Arrays;
operators +, -, %, / (truncates for int)
add element list.add((i), e) multi-dimensional arrays: arrays of arrays.
increment/ ++, --
remove list.remove(i or e) elementType [rows][columns]
decrement
element arrayVar
operators
remove all list.clear()
instance a method that can only be
elements Vocabulary
method invoked from a specific object
import java.util.ArrayList; composition information belongs to one
local within a method
object
variable
Important methods association/se information can belong to
instance dependent on the specific
modifier returnValueType gregation many objects
variable instance (class)
methodName(params){ public can be seen anywhere in any
overloading methods can have the same
public Class ClassName{ visibility package
methods name as long as their method
public static void main (String[] args) private can be seen within class signatures are different
visibility
Scanner input= new Scanner(System.in) binary operators are left-associative,
System.out.println(line); protected in package and subclasses of assignment operators are right associative
visibility this in any package
public static type name (type param){
return type; } runtime error crash