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
Win a copy of
Murach's Java Servlets and JSP
this week in the
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
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.
It is sorta covered in the
JavaRanch Style Guide
subject: Array declaration
Instance Initializer and Forward Referancing
Class Variable access
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014