• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About Object class problem?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class gc1{
static Object xx;
public static void main(String[]args){
Object oa1=new Object[10];
Object oa2=new Object[0];
Object[] oa3=new Object[0];
System.out.println(oa1);
System.out.println(oa2);
System.out.println(oa3);
System.out.println(xx);
}
}//what's the different from oa1,oa2,oa3,xxand what's the meaning oa1,oa2,oa3,xx?I can't get it?
[ March 02, 2002: Message edited by: Tu Ran ]
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tu,
oa1, oa2, oa3 are all arrays of type Object, and xx is a reference to Object, which is currently empty (null). Not sure if this is what you are looking for??
/rick
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No,
oa1 is a variable of type Object that happens to hold a reference to a Object[] of size 10.
oa2 is a variable of type Object that happens to hold a reference to an Object[] of size zero.
oa1 and oa2 are NOT Object arrays.
oa3 is a variable of type Object[] (Object array) that happens to hold a reference to an Object[] of size zero.
xx is a variable of type Object that happens to hold a value of null.
Bill
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic