Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

what is wrong with the code?  RSS feed

 
Dana Horst
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys, here is the code




when i run it, i get an error "Printer started with null constructor" in stead of "x is 0, y = 1" etc. where is the mistake in the code? thank you
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code works fine for me when I run it. Are you sure that's the code you're running? Is there possibly another Printer class that might be interfering?
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing wrong with your code. I compiled and run it without problem and I've got the expected output.
What are your steps to get this error?

EDIT:
ONE second later than Matthew!!!
 
Dana Horst
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I run the code in Eclipse. run as - 1 Java Bean.
And yes, i am sure i run the right code. but still get this strange melding
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dana Horst wrote:I run the code in Eclipse. run as - 1 Java Bean.

That's not a Java Bean. You need to use the Run As Java Application option.
You also need to make sure you're running the SubPrinter class and not the Printer class as that's the one with the main method in it.
 
Dana Horst
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, it helps! thank you xx
 
Ankush Kaundal
Ranch Hand
Posts: 36
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The better way can be to run and test the code via command line which can help to learn the basics in a more effective way...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!