Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] question about an array of objects

Started by omegasyphon Nov 29, 2001 at 4:40 PM 6 replies 350+ views
Original Post
omegasyphon
omegasyphon
im trying to set an array objects to 0 but the following way doesnt seem to work but i dont know why it wouldnt
  

	public void makeEmpty()
        {
            for (int x=0;x<myList.length;x++)
            {
                (Comparable)myList[x]=0;
            }
	}
  
mylist is defined as an array of comparables
WayfarerX
WayfarerX
try:

myList[x] = null;

in Java, null & 0 are NOT the same thing.

"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool
------------------------------
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
c_wraith
c_wraith
"won''t work"?

Can you please be more vague?
FLCman
FLCman
We need to see some more code. I think I might have an idea but assumption is the mother of all f*&k ups.
omegasyphon
omegasyphon
well i dont know what else to show you but null just gives me the same error as setting it to zero

it says this

"SortedArrayList.java": Error #: 361 : variable required, but value found at line 124, column 17


  
private Comparable[] myList; // this is how it is initialized

omegasyphon
omegasyphon
i fixed the problem

doing this worked

myList[x]=null;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.