Friday, May 21, 2010

Question in java??

I have wrote a method push(Object o) that take an object...


and i write it in a Interface ..


but i want to use it like this { push(char c))??


how i can cast from OBJECT to char??


thnx.

Question in java??
like this :


push(Character character);





or u can leave it like this : push(Object obj) in interface


and then from object u will invoke it like this





obj.push(Object(new Character('A')));
Reply:to cast it just use:


push((Object)char);





but you could make another interface for using specifically char's


No comments:

Post a Comment