Extends

From Abap2Java

Jump to: navigation, search

ABAP

Translation:
INHERITING FROM

CLASS Vehicle DEFINITION.
   PROTECTED SECTION:
     INT4 wheels.
   PUBLIC SECTION:
     METHODS constructor IMPORTING iv_wheels TYPE INT4.
ENDCLASS.
CLASS Vehicle IMPLEMENTATION.
   METHOD constructor.
     me->wheels = iv_wheels.
   ENDMETHOD.
ENDCLASS.
CLASS Car DEFINITION INHERITING FROM vehicle.
   PUBLIC SECTION:
     METHODS constructor.
ENDCLASS.
CLASS Car IMPLEMENTATION.
   METHOD constructor.
     super->constructor( 4 ).
   ENDMETHOD.
ENDCLASS.

Java

The extends keyword indicates that a class inherites from another class.

class Vehicle {
   protected int wheels;
   public Vehicle(int wheels) {
      this.wheels = wheels;
   }
}

class Car extends Vehicle() {
   public Car() {
      super(4);
   }
}
Personal tools