Java Reference
In-Depth Information
Program 8.11 Heap: Prototyping object methods
int maxHeap ( )
return this . label [0];
}
void add( int element)
{ ...
}
void removeTop ()
{ ...
}
8.5.2 Object-oriented lists
Similarly, we can revisit the static functions formerly defined on linked lists to
fit the object-oriented programming paradigm as follows:
Program 8.12 Linked list with object methods
public class List
int element ;
List next ;
List( int el , List l )
this .element=el;
this .next=l;
}
static List EmptyList()
return new List (0, null );
}
boolean isEmpty ()
return ( this .next== null );
}
}
The other various functions of linked list interface are then redefined as the
following object methods:
 
Search WWH ::




Custom Search