Skip to content

Instantly share code, notes, and snippets.

@CameronCarroll
Created April 23, 2012 17:03
Show Gist options
  • Save CameronCarroll/2472310 to your computer and use it in GitHub Desktop.
Save CameronCarroll/2472310 to your computer and use it in GitHub Desktop.
constructor (java)
/* Java: Constructor example */
/* example code from http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html */
/* constructor method */
public Bicycle(int startCadence, int startSpeed, int startGear) {
gear = startGear;
cadence = startCadence;
speed = startSpeed;
}
/* Instantiating a new object using 'new' keyword */
Bicycle myBike = new Bicycle(30, 0, 8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment