Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

void type not allowed

 
Malcolm Bibins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where exactly am I going wrong?



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

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's complaining that you can't do

since that method is void.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48386
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
change your method to this:

 
fred rosenberger
lowercase baba
Bartender
Posts: 12085
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Malcolm Bibins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. Yeah this helped a ton. Thanks folks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic