I am trying to cast methods from a cloned array. However, I'm experiencing some issues. Here's the code:
Array1[] a = new Array1[] {
"new Array1("exampletext", 0.5, 205)
};
Object[] o = a.clone();
System.out.println(o[0].getSomething());
It works when I use the "original" object. I thought the cloned object was an exact copy. Can anyone tell me whats going wrong there or give me some hints?
Edit: Okay, here's the real code ( I can't compile it as well tho! )
Drinks[] gtrk = new Drinks[] {
new Drinks("Drink1", 0.90, 205, 0.5 ),
new Drinks("Drink2", 0.90, 190, 0.5 ),
new Drinks("Drink3", 0.70, 150, 0.5 ),
new Drinks("Drink4", 20.50, 500, 2.0 ),
new Drinks("Drink5", 28.70, 360, 1.5 ),
new Drinks("Drink6", 6.90, 2500, 12.0 )
};
public void objectArrayTest() {
Object[] o = gtrk.clone();
System.out.println(o.getName());
}