aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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!
 
jQuery in Action, 2nd edition
 
subject: Calling a class to output print within another class?
 
Similar Threads
99 bottles of beer song.......
Help.
Craps Game Code
Create a Die Class
Bad operand types for binary operator?