programming wrote:
> Hi all, i was just wondering with the below program what effect what
> type casting have on the final output. I tried compiling the sample
> below, but there were to many bugs in the program to get it to work. I
> think that type casting would copy the value "cufflinks for Aus" into
> T2, and it would be printed out twice. Can somebody verify this with
> me.
>
>
> public class Thingy
> {
> public TextField value;
>
> public Object clone()
> {
> Thingy n;
>
> n=new Thingy();
> n.value=this.value;
>
> return n;
> }
> }
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------
> public class Question
> {
> Thingy t1,t2;
>
> public static void main(String args[])
> {
>
> t1= new Thingy();
>
> t1.value.setText("Cufflinks for Aus");
>
> t2=(Thingy) t1.clone();
> t2.value.setText("Bah Humbug!");
> }
>
>
> }
Hmm, I think its time for you to get a Java book.
|