Can we declare a variable as Object type?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ravikumar_Ponraj
Posted On:   Friday, September 22, 2006 12:20 AM




Hi,

is it possible to declare a variable as



Object obj=100;
or
Socket s = 100;




as we declare int i=100;


If so, kindly let me know the way of declaraion and how to

print the value.



Thanks in Advance,
Moses.


Re: Can we declare a variable as Object type?

Posted By:   WarnerJan_Veldhuis  
Posted On:   Friday, September 22, 2006 02:32 AM

No you can't, and if you think about it, it does not make any sense at all. Try walking into a bakery, a butcher, or a clothing store, and ask for 100. They will not understand. Same goes for objects. If you setup a Socket variable, it needs a Socket (or one of its sub-class) to be assigned to it. 100 is not a Socket.
About | Sitemap | Contact