File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 38519
    
  23
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: 11257
    
  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.
 
wood burning stoves
 
subject: void type not allowed