Is this a right way to put Java generics in action? -


I have started messing with the generic and I have to ensure that I got this right, any help?

  Public Interface Cart & lt; Tee CartItem & gt; {Public Zero Settings (List & lt; T & gt; Items); Public listing & lt; T & gt; GetItems (); } Public Interaction CartItem {Public BigDecimal getQty (); Public zeros set (Bigdishci kwati); // more} public category cart service & lt; T, cart & lt; E & gt ;, E increases CartItem & gt; {Public Zero addOrReplaceItem (T-cart, e newCartItem) {List & lt; E & gt; Item = cart.get items (); Int Status = Items Index (newcartime); If (status> gt; -1) {e present item = items.jet (status); CurrentItem.setQty (existing ITem.getQty) .add (newCartItem.getQty ())); } And {items.add (newCartItem); }}} Public interface grocery cart extension cart and lt; GroceryCartItemImpl & gt; {// more} Public interface grocery cart eTam spreads {// more} Public category grocery rent ITemImpl applies Serializable, GroceryCartItem {// more} Public class GroceryCartImpl applies Serializable, GroceryCart {// more}  

Calling service:

  GroceryCartImpl GC = ............ Marriottmate IMPLGC = ........ ... cart service & lt; CARRIERCARE ACT IMPLIP, MARIKARE ITEMMLOGS & gt; CS = new cart service & lt; CARRIERCARE ACTIMPLY, MARIARITAITIMIMIMple & gt; (); Cs.addOrReplaceItem (GC, GCI);  

Your code looks good @ Wrong statement with Shadow Nob should be done " should be there.

I agree with @Sudo Nob, you should change the lines:

  GroceryCartImpl gc = .......... MaricartITIMPPLGC = .. .........  

... with:

  GroceryCart GC = ........... . GroceryCartItem gci = ...........  

But its nothing to do with generics.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -