Results 1 to 2 of 2
Thread: Return question in a method.
- 01-13-2008, 04:29 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 2
- Rep Power
- 0
Return question in a method.
I need to return more than one variable from a method I run.
The first time the method is every run, it will return a 1, and every time it is run after that, it will return a 0 instead. I've got that down pat. Now, after the method does a few things from the user, I want it to return another variable (int) also, which I want to use to add to another variable in my main method.
Is this possible? I'm sorry that I'm so new to Java. :(
Example:
public class itemShop1 {
public static int itemShop(int beenBefore) {
if(beenBefore == 0) {
return 1;
}
else {
return 0;
}
// More code here, where people can buy items, and it returns the amount bought, and deducts a given amount of gold.
}
}
- 01-13-2008, 04:45 AM #2
Member
- Join Date
- Jan 2008
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Error: invalid method declaration; return type required
By silvia in forum AWT / SwingReplies: 3Last Post: 06-05-2010, 08:05 PM -
return a null method
By valoyivd in forum New To JavaReplies: 2Last Post: 04-21-2008, 11:19 PM -
return Set .toArray(); method as an array of integers
By maxim in forum New To JavaReplies: 2Last Post: 04-16-2008, 12:35 PM -
Simple Method Question
By Froz3n777 in forum New To JavaReplies: 2Last Post: 02-13-2008, 02:39 AM -
Return value of method
By cachi in forum New To JavaReplies: 1Last Post: 08-01-2007, 08:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks