File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes 'void' type not allowed here Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Meteor in Action this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " Watch " New topic

'void' type not allowed here

Arun C. Giridharan
Ranch Hand

Joined: Jul 11, 2010
Posts: 96 'void' type not allowed here

what does this mean 'void' type not allowed here ???
David Newton

Joined: Sep 29, 2008
Posts: 12617

Can't print a void return value. Either return a string, or do all the printing in bark().

Personally, having a method that prints " says Ruff!", and depending on the calling method to put something in front of it that makes sense, is the start of a bad API. Options would include just returning "ruff" and doing the additional work in the calling method, or doing the name + barking sound in the bark() method, but there are other options as well.
Arun C. Giridharan
Ranch Hand

Joined: Jul 11, 2010
Posts: 96
Thank you .... i forgot about return type (String)
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: 'void' type not allowed here