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 Array dimension missing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array dimension missing" Watch "Array dimension missing" New topic
Author

Array dimension missing

Stephanie Dears
Ranch Hand

Joined: May 26, 2005
Posts: 43
I have a line in my code:

int array = new int[] array;

the error is array dimention missing

What does this mean?

Steph
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

To declare an array you need something along the lines of

int[] anIntArray = new int[10];

This declares 'anIntArray' to be an array of length 10.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Stephanie Dears
Ranch Hand

Joined: May 26, 2005
Posts: 43
It's reading from a .txt file.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

You can declare an array of unknown size like this:

int[] array;

but there's no array object there. You can't use "new" to actually create the object until you actually know the size.

If you don't know the size -- that's what we're talking about here, right? -- then don't use an array: use one of the Collections classes in java.util. For example, java.util.ArrayList, which is rather like an array, but it grows automatically as you add items to it.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array dimension missing
 
Similar Threads
How to select an image from an array Help!
Another Mock Exam Question
Learning Project 2
Array Declaration doubts
aggregate initialization