I have never read the data structures of other language versions, but I think java implementation methods are clever-using classes and objects for implementation. an array-based table defines a class to store a group of data. I define the ArrayListClass class and the method to operate arrays in the class. this is actually so simple, but the specific operation will encounter a lot of trouble!
In our ArrayListClass class, we should first include an array-type domain list to store data. In this way, data in the same Array produces a positional relationship, data operations are easy. however, what data type is this array? We expect this table to be used for all data types. We cannot fix it simply into a certain type. therefore, we must make this data common. The solution is to define a class as a superclass for all data types. check this DataElement:
Public abstract class DataElement {
Public abstract boolean equals (DataElement otherElement );
Public abstract int compareTo (DataElement otherElement );
Public abstract void makeCopy (DataElement otherElement );
Public abstract DataElement getCopy ();
}
It is defined as abstract and inherited and implemented when other data types are defined. I have defined two data types: IntElement and StringElement:
IntElement:
Public class IntElement extends DataElement {
Protected int num;
// Constructors
Public IntElement (){
Num = 0;
}
Public IntElement (int number ){
Num = number;
}
Public IntElement (IntElement otherElement ){
Num = otherElement. num;
}
/// Get-set Methods
Public void setNum (int number ){
Num = number;
}
Public int getNum (){
Return num;
}
/* (Non-Javadoc)
* @ See DataElement # equals (DataElement)
*/
Public boolean equals (DataElement otherElement ){
// TODO Auto-generated method stub