• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

java error

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\Sun\AppServer\jdk\bin\Student.java:31: array dimension missing
Student pupil[i] = new Student[];
^
1 error

I have tried corrected but it seems that I am not setting up my array correctly.

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on your comment,

// create an array of 10 student objects from class Student...

your array declaration would look like

Student[] students = new Student[10];

Note that you want this outside your for loop, not inside; you want to create the array, then visit each element, right?

Now, this just gives you an array of 10 Student variables; the variables are all null. If you need objects, then you need to create those too; for example, inside your for loop, at the top, you might have

students[i] = new Student();

this would fill each element of the array with a Student object as you visited it.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic