Skip to content

Instantly share code, notes, and snippets.

@rebekah
Created October 29, 2023 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebekah/4eb1a31c95fabce2672dde26f2bed381 to your computer and use it in GitHub Desktop.
Save rebekah/4eb1a31c95fabce2672dde26f2bed381 to your computer and use it in GitHub Desktop.
Basic Inheritance
//Vehicle.java
public class Vehicle {
String color;
}
//Truck.java
public class Truck extends Vehicle {
int bedLength;
}
//TruckDemo.java
class TruckDemo {
public static void main(String[] args){
Truck myTruck = new Truck();
myTruck.bedLength = 2;
System.out.println(myTruck.bedLength);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment