Refer to the Code.org notebook for examples of how to use objects!

Classes

Classes are how objects are made. Without a Class, you cannot create an object. Each class has its own seperate java file (named with .java). A class can have variables and methods.

Class Instances

These are the objects themselves. To call an object, you want to do

Name name = new Name();

Where “Name” is the Class name and the “name” is the object name

You can call a method by doing object.method();

Object Mutating Data

Mutating data is basically where you are changing one form of data into another form. An example of this was where we converted a primitive data type into the Wrapper class. It is possible for an object to do this and convert some data type into another.

Extends

Extends can allow a class to inherit everything from another class, but allows additional features to be added. The class the is inheriting is the subclass, while the original class is the superclass.

The syntax to extend is extends superclass.

Loops

There are 2 main loops, while loops and if loops.

  • While loops run while something is true.
  • If loops run when a certain condition is met
    • If loops can have an “else” line too to give an alternate function if the condition is not met in the “if” part of the loop.