You are on page 1of 4

ArrayList of String

Type of objects it will contain : <String>


Private ArrayList <String> files;
ArrayList is a generic class
Add, get, size, etc.

Example

private ArrayList<ClockDisplay>clockList;
private int x;

Constructors stores initials values into the fields


Initializes the object.

Methods implement the behavior of the objects


SETTER
Public int getPrice()
method name)

(this is the header of the method, getPrice is basically the

String, int, and Boolean - CANNOT BE VOID, these will always return a value, will
contain a return statement to return the value. Return means it finishes the method
and take you out of the method.
Strings represent text

MUTATOR
This is used to change an objects state. (use void)
Public void insertMoney (int amount) - amount is a parameter, it goes into the
function
{
balance = balance + amount; (balance is being mutated, balance + amount
is the assignment statement)

PSUEDO CODE, just to describe what a code can mean

If (I have enough money left)


{
go out for a meal; (actions if conditions is true)
}
Else {
Stay home and watch a movie; (actions if conditions is false)
}

Variables
-

Allocation of memory for a specific type


public int x;

Field variables
-

defined at the top of a class


they are accessible throughout the class

Parameter variable
-

defined in the method header


used to receive values from the outside the method
are short lived

local variables
-

short lived, like parameters


used for temporary calculations
only accessible from within the method

Binary logical operators


Used in control structures like if statements:
&& = And (if((replacementValue >= 0) && (replacementValue < limit))
|| = Or
! = Not
== Equal to , single = is just assignment (int x = 3)
!= not equal to

Internal method call


updateDisplay();
external method call
minutes.increment(); ( object. Methodname (parameter list) ; )

index ++;
is index = index + 1;
LOOPS (for and while)

Overriding object methods


Public toString method
Overriding equals

For loops
For (int I =0; i < 10; i++)

{
System.out.println(I is equal to + i)
}
While i is less than 10 and increment by 1 every loop.

Example of finding object in an ArrayList


Person findId(int id, ArrayList<Person> al) {
2
3
for(Person p : al) {
4
if(p.getId() == id)
5
return p;
6
}
7
8

throw new IllegalStaeException("Id: " + id + " is not in the list");

You might also like