OOP - Week 2 Flashcards
What is changing to a bigger or smaller type called
Widening/Narrowing
How to type cast
Write (typename) infront of the variable name
What is an array
A container that holds a fixed number of values of a certain type
How to make an array
(type) [] (arrayname) = new (type)[number]
How to quickly initialise elements
(typename) [] (arrayname) = {values};
If syntax
if (condition) { //code }
While syntax
while (condition){ //code }
do syntax
do { //code } while (condition);
switch syntax
switch (expression) { case value 1: //code break;
default: //code break; }
for syntax
for (i=start; i
What is block scope
A variable declared inside a pair of brackets in a method
Break and Continue
Break - breaks out of the loop
Continue - ends the current pass of the loop
How to make a for each loop
datatype [] arrayname = ... for (datatype name : arrayname) { //code }
Syntax of methods
public static datatype name (arguments) { //code }
How to make a method no output
public static void