DATA TYPE REF TO
From Abap2Java
(Redirected from DATA...TYPE REF TO)
[edit]
ABAP
The variant DATA...TYPE REF TO of the keyword DATA is used to declare a variable that is a reference to an object or other data (DATA...TYPE REF TO DATA).
DATA lr_my_object TYPE REF TO cl_my_class. "declares the variable DATA lr_my_data_reference TYPE REF TO DATA.
lr_my_object->some_method( ). "will dump, because the variable is not bound IF lr_my_object IS BOUND. "checks if the variable is bound "... ENDIF.
CREATE OBJECT lr_my_object. "now, the object is created, the constructor is called, and the variable is bound
[edit]
Java
In Java, variables are defined without a specific keyword.
int lv_my_variable; //integer variable String lv_my_string //string variable MyClass myObject; //reference variable (reference to the class MyClass) myObject->some_method( ); //will dump. because the variable is not bound if myObject == null{ ... } //checks if the variable is bound myObject( ); //by this call of the constructor, the object is created and the variable is bound.
Variable definitions can have modifiers that define the visibility (public, protected, private) and other properties of the variable (final, abstract, static etc.).
The ABAP variant TYPE REF TO does not need a special keywork in Java, since references to classes can be defined like any other variable.

