File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Jan 31, 2008
Mar 19, 2008 09:22:00
Is this declaration correct:
int arr = new int;
Joined: Oct 27, 2005
Mar 19, 2008 09:26:00
No it isn't.
The declared type is int - array of integers.
The initialized type is int - array of array of integers.
So either add a  in the declaration, or remove the  (keep the ) in the initialization.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
Joined: Apr 14, 2004
Mar 19, 2008 09:27:00
No. Doesn't your compiler tell you this?
int arr =
creates a variable which references a one dimensional array of primitive integers.
creates a two dimensional array of primitive integers.
You can't assign one to the other.
I agree. Here's the link:
subject: Array declaration
Class Variable access
Instance Initializer and Forward Referancing
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015