What is a constructor?
special types of methods that are responsible for creating and initializing an object of that class
How do you create a constructor?
Same as methods except:
They can however take input parameters like a normal method, and you are allowed to create multiple constructors with different input parameters.
class Game{
...
// Constructor
Game(){
// Initialization code goes here
}
...
}What is a default constructor?
doesn’t take any input parameters at all!
if you don’t create a default constructor, Java will automatically assume there’s one by default that doesn’t really do anything.
Loops
What is the shorthand for?
i++;
i = i+1;
Loops
What is the shorthand for?
i = i-1;
i–;
Loops
What is the shorthand for?
i = i+5;
i += 5;
Loops
What is the shorthand for?
i = i-6;
i -+ 6;