generics - Is my code correct? UML-> Java translation -


I was just going through some examples of UML Diagram, being translated into Java, and I I'm stuck in I am giving illustrations as a reference:

UML

< P> Since I am very new in Java programming, I do not understand anything in this code: Why do I have to add Linkedist? Tie on the right corner of the garage: What does tier mean? (Gehege = Zoo, Tiere = Animal in German)

category of public category {Private int unjelabine; Private string Farbe; Public Tier (Int Engelbin, String Farbe) {this.anzahlbeine = anzahlbeine; This.farbe = Color; } Public Zero Laufen (double strik) {System.out.println (strecke); } Public zero fressen () {System.out.println ("I eat"); }}

and

  public square Gehege & lt; T extended range & gt; {Private Ent. Compatit; Private double grosses; Private linked list & lt; T & gt; Tiere; Public gehege (int kapajitaet, double groesse) {this.kapazitaet = kapajitaet; This.groesse = groesse; } Public Zero addTier (T level) {if (this.kapazitaet> this.groesse.size) {this.tiere.add (tiere); } And {new exceptions RunTimeException ("full"); }} Public Zero Deletion Tier (T level) {this.tiere.remove (tier);}}  

This means that is templatized with Gehege

code> Tier . Although everything is syntactically correct, that is not true. There are different types of Gehege that are different types of things? This is not very right! Take an example of

list . The list is templatized because there can be a list of different types of items - list of car , list of < Code> Book etc. Apply the same object to gaage - the argument falls flat so in my opinion the design is not correct in the right way.


Comments