File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes is it a Object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "is it a Object?" Watch "is it a Object?" New topic
Author

is it a Object?

pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
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??
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

See JLS - 10 Arrays...
In the Java programming language arrays are objects...


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
nilesh purohit
Greenhorn

Joined: Oct 31, 2007
Posts: 4
a is a reference variable pointing to an array of ten integers.array is an single object created on the heap
pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
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?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

'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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is it a Object?
 
Similar Threads
How many objects are created by the following two statements?
Conversion of reference values
is Arrays are Object?
How many objects are created by the following two statements?
Difference between c++ and java Object creation