• 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

is it a Object?

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
int []a=new int[10];

/***how can you create a object out of primitive types************/

in the above code is 10 objects created or 10 integers??
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by prasanna sheregar:
int []a=new int[10];

/***how can you create a object out of primitive types************/

in the above code is 10 objects created or 10 integers??


1 object and 10 integers.

The object is the array itself, with inside it 10 integers (all with value 0).
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See JLS - 10 Arrays...

In the Java programming language arrays are objects...

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a is a reference variable pointing to an array of ten integers.array is an single object created on the heap
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class neeti {

static int year[]; /*****************8DOUBT*********/

public static void main(String args[]) {
System.out.println(year);
}
}

/********** doubt*********************/

is there a object reference there --- the DOUBT line...or is it a primitive?
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'year' is a reference variable. it points to a object that is an Array, and that array can only hold ints. the compiler is kind, and initialized each of those 10 ints to 0 for you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic