This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Calling a class to output print within another class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling a class to output print within another class?" Watch "Calling a class to output print within another class?" New topic
Author

Calling a class to output print within another class?

Brian Mart
Ranch Hand

Joined: Apr 17, 2012
Posts: 34
Hi,
This seems like a basic problem, but I am having a lot trouble solving it. Basically, I need to output all of the rules from the class rules if the criteria are met in the nested if statement in the class Craps. There is more code after rules, but it is irrelevant. My compiler tells me "cannot return a value from method whose result type is void".
I realize I could simply copy and paste the entire rules class to the spot in the nested if statement, but this is not kosher according to my professor. Can someone point me in the right direction please

Panagiotis Kalogeropoulos
Rancher

Joined: May 27, 2011
Posts: 99

There is no need to call return when you want to call also the rules method. If you omit the return keyword your code will work fine.

Also something very important: you should compare Strings using the equals method, not the == operator.
Brian Mart
Ranch Hand

Joined: Apr 17, 2012
Posts: 34
It was so simple.... Thanks!
Panagiotis Kalogeropoulos
Rancher

Joined: May 27, 2011
Posts: 99

You're welcome!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Calling a class to output print within another class?
 
Similar Threads
Craps Game Code
Bad operand types for binary operator?
Help.
99 bottles of beer song.......
Create a Die Class