<<< Method overloading (Java)     Index     How the super class is constructed >>>

9. Using UML to Model classes


  • DataBaseReader class diagram lists two constructors.

  • Without the parameter list, there is no way to know which constructor is which:

    
    public class DataBaseReader {
        String dbName;
        int startPosition;
        // initialize just the name
        public DataBaseReader (String name){
            dbName = name;
            startPosition = 0;
        }
        // initialize the name and the position
        public DataBaseReader (String name, int pos){
            dbName = name;
            startPosition = pos;
        }
        .. // rest of class
    }
    
    
  • Class diagram for the DataBaseReader class:

      DataBaseReader class diagram

<<< Method overloading (Java)     Index     How the super class is constructed >>>