Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How come this keeps on getting overwritten?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ericfourfour




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Thu Oct 05, 2006 10:02 pm   Post subject: (No subject)

Ok, I fixed it. I figured out it had to do with 'static' stuff.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: