Objects

howtosurvivecomputerscienceincollege

Java is an object orientated programming language (so is c++ and python) which means that the programming is centered around using classes and methods to create objects, and then using those objects in your code. I will take two posts to explain objects, the first will be how to create objects, and the second will be to show all of the different functionality that objects have.

An object is something that has different states and behaviors for example a bear has states such as color, type, ..ect and a bear has behaviors such as growling, eating, sleeping. You create an object by creating an instance of the class that the object is defined in.

public class Bear {

private String color;

public Bear(int age, String type) {

this.age = age;

this.type = type;

}

void growling() {  }

void eating() {  }

void sleeping() {   }

}

so this…

View original post 258 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s