aspose file tools*
The moose likes Beginning Java and the fly likes void type not allowed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "void type not allowed" Watch "void type not allowed" New topic
Author

void type not allowed

Malcolm Bibins
Greenhorn

Joined: Mar 12, 2013
Posts: 7
Where exactly am I going wrong?



It highlights the string "turns 21 in" as the error.

Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

It's complaining that you can't do

since that method is void.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

In the future, please UseCodeTags(⇐click) when posting code, so it will be readable. I've added them for you this time.

And welcome to the Ranch!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39425
    
  28
What Jeff means is that you must have something after the + operator. If your method is void, then there is nothing there, and the + operator cannot operate on nothing.
Shannon Graham
Greenhorn

Joined: Mar 11, 2013
Posts: 14
change your method to this:

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11419
    
  16

even better, I'd ditch the Difference variable all together, and just have the method return the computed value each time.

if you insist upon keeping it, at least follow proper naming conventions and call it "difference".


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Malcolm Bibins
Greenhorn

Joined: Mar 12, 2013
Posts: 7
Okay. Yeah this helped a ton. Thanks folks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: void type not allowed