Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why can't I do this? toString() question.

807607Oct 19 2006 — edited Oct 19 2006
ArrayManipulater dataSet1 = new ArrayManipulater();

System.out.println(dataSet1.createRandomArray().toString());
It says cannot invoke string on the primitive type void.

I instead have to do this to make it work.
ArrayManipulater dataSet1 = new ArrayManipulater();

dataSet1.createRandomArray;

System.out.println(dataSet1.toString());
Also, I don't really get the difference between the built in toString functionality and a self-written toString method in a class. We were told to write a toString method that prints out an array but how does the compiler interpret our toString method versus the built-in toString method.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2006
Added on Oct 19 2006
8 comments
848 views