java - Problems with toString(), how to use without calling the object -


sorry if question doesn't make sense. also, i'm limiting code here, , try same assignment, , plagarism checkers annoying :/

so, assignment in java, have define method in iterates until simple game one, printing out tostring() representation between every move. however, have been unable work, there no object created of class...

i've tried call tostring() method without object before it, doesn't print. , i've tried this.tostring() well. pretty code below basic mock of method/class (not do)

public randclass {  randclass() { box box = new box(); square square = new square(); duck duck = new duck(); }  public void dosomething() { tosring(); // tried this.tostring(); { box.postion ++; square.position = 100 - box.position; this.tostring(); } while(duck.quack() != true);| }  public string tostring() { return box.tostring() + " " + square.tostring() + ";"; }  } 

i realise call box.tostring() etc. in place of using tostring() method call, however, assignment asking randclass object tostring() method defined.

the tostring has worked, automated marker creating randclass object , calling method.

thank in advance taking time read this, , sorry being confusing :(

tostring() in , of doesn't print anything, returns string representation of object of member.

you'll have pass string on stream of sort have printed screen or file. say, println method of outputstream, perhaps static 1 contained in system, possibly named 'out', instance.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -