Created
April 23, 2012 17:03
-
-
Save CameronCarroll/2472310 to your computer and use it in GitHub Desktop.
constructor (java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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