Meaningless Drivel is fun!
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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)
I agree. Here's the link:
subject: 'void' type not allowed here
It's not a secret anymore!