removing from map

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    #1

    removing from map

    can i remove an element from map using

    if("Roza Czerwona".equal s(nazwa_kwiata) ){
    zawartosc.remov e(new RozaCzerwona()) ;
    }
    it seems that it doesnt work
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by oll3i
    can i remove an element from map using

    if("Roza Czerwona".equal s(nazwa_kwiata) ){
    zawartosc.remov e(new RozaCzerwona()) ;
    }
    it seems that it doesnt work
    That wont work. You are creating a new RozaCzerwona and trying to remove it from zawartosc where it has not been put.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by r035198x
      That wont work. You are creating a new RozaCzerwona and trying to remove it from zawartosc where it has not been put.
      That all depends whether or not the OP has implemented the equals()
      and hashCode() methods correctly for that particular class. The code
      fragment does smell funny though.

      kind regards,

      Jos

      Comment

      • oll3i
        Contributor
        • Mar 2007
        • 679

        #4
        i changed it to arraylist now i need to remove eg RozaCzerwona() from that list
        should i define equals method for RozaCzerwona () and every other flower that may be in that list ?
        how should i remove it?

        Comment

        • oll3i
          Contributor
          • Mar 2007
          • 679

          #5
          okey i solved it thank you very much

          Comment

          Working...