The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Object c = new long[4]; Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Object c = new long[4];" Watch "Object c = new long[4];" New topic
Author

Object c = new long[4];

Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 168

What is this line of code doing:



Why are the square brackets used "[]" ?


OCPJP 6, OCMJD
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 4094
    
  18

You are creating a new array of long, with length 4, and assigning it to an Object variable. Recall that arrays are objects too.

You know about arrays, right?


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 168

Thanks Stephan.

I had studied too much yesterday. That line of code made no sense to me. All is clear after a good nights sleep. Thanks again. :-)
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 4094
    
  18

We all have moments like that. Happy to help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Object c = new long[4];
 
It's not a secret anymore!