• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object arrays?  RSS feed

 
Brandon Choate
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again,
I need to know how to populate an array object in java.

Here is my code so far:


I want to fill each level of the array with a string for the ID of the course, the name of the student, and so on.

Problem is, none of my books go into Array objects like this in any detail. Only one of the books contains a single line even telling you that an array can be made out of an object like this.

I think I could get it to simply fill in an unaffiliated number for each level, but getting it to read a string, or even getting multiple strings into the same level is beyond me.


So, any pointers? Any ideas where to go from here?
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brandon,

This link should help.

John.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Brandon Choate
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Lets say I have yet another problem.


Since I made the above post, I've gone a different route. Making a different array for every individual component.

Everytime I try and fill in a variable, it gives me this error message when I compile:

Transcript.java:16: ']' expected
sID[0] = 108;
^
Transcript.java:16: <identifier> expected
sID[0] = 108;
^

WHY!? I copy something directly out of the book, and it still gives me this! What is the correct way to input something in an array?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Transcript.java:16: ']' expected


When the compiler complains about something expected at a line -- it is generally caused by something from the preceding lines. So, we need to see code from the Transcript class, in this case.

Henry
 
Varun Goenka
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not use an arraylist Brandon?
Your code will be cleaner and you really wont be held back by the limitations that arrays come along with.
Come on you are dealing with objects anyways why use a clunky solutio like array???
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!