Computer Science Canada

How come this keeps on getting overwritten?

Author:  ericfourfour [ Thu Oct 05, 2006 9:42 pm ]
Post subject:  How come this keeps on getting overwritten?

code:

MenuItem item1 = new MenuItem ("1: Create User Account", "1", create);
item1.display(); //output item 1
MenuItem item2 = new MenuItem ("2: Load User Account", "2", load);
item1.display(); //output item 1 again


When I display item1 the first time it works alright but when I display it after I create item2 it displays what item 2 should.

The output looks like this:

1: Create User Account
2: Load User Account

but it shouldn't because I only asked it to display the fist one. It appears that the first one is getting overwritten.

It should look like this:

1: Create User Account
1: Create User Account

I'm kindof a noob to this OO stuff in java so some good links would be helpful.

Author:  ericfourfour [ Thu Oct 05, 2006 10:02 pm ]
Post subject: 

Ok, I fixed it. I figured out it had to do with 'static' stuff.


: