• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with 2-dimensional array  RSS feed

 
Dan D'amico
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i wrote this code which print a black image depends on the number of rows and coloms you give it

my problem is that my output comes good except the last line ,
Output:
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
BlackImg@1db9742
//what is this line , why does it showing up ?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think your line 26 does?
 
Dan D'amico
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:What do you think your line 26 does?


prints the address ?
i saw the excatly same procedure in another class (the test class)
the person that wrote the code did excatly what i did

and the output was like mine but without the address.
so the problem is in the BlackImg class , what i did wrong in the BlackImg class ?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan D'amico wrote: what i did wrong in the BlackImg class ?

It's more a case of what you didn't do
 
Dan D'amico
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but for the exercise i need to do this this way System.out.print(black);

and not thisSystem.out.print(black.toString());

so the only way is to use a toString method inside the constructor?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan D'amico wrote:but for the exercise i need to do this this way System.out.print(black);
and not thisSystem.out.print(black.toString());
so the only way is to use a toString method inside the constructor?

That's not what Joanne was referring to.

Have a look at the definition for PrintStream.print() and find out what it does. You might also want to look up the API docs for Object.toString().

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!