View Single Post
  #6 (permalink)  
Old 10-31-2007, 12:26 AM
ShoeNinja's Avatar
ShoeNinja ShoeNinja is offline
Senior Member
 
Join Date: Oct 2007
Posts: 123
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
Since the string that you passed into the constructor is called 'name', when you say name = "HP" you're changing the String that was passed in. The name attribute of the class is never initialized which is way you are getting null.

Change it to:

Code:
public MyPrinter(String name, int startPaper) { copies = 0; this.paper = startPaper; this.name = name; }
Then when you call the constructor:

Code:
MyPrinter foo = new MyPrinter("HP", 200);
Give that a try.

They shouldn't be too tough. If you can't figure it out, put another post up.

Last edited by ShoeNinja : 10-31-2007 at 12:32 AM.
Reply With Quote