Results 1 to 2 of 2
  1. #1
    MetalGear is offline Member
    Join Date
    Jan 2008
    Posts
    2
    Rep Power
    0

    Default 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.
    }

    }

  2. #2
    MetalGear is offline Member
    Join Date
    Jan 2008
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Replies: 3
    Last Post: 06-05-2010, 08:05 PM
  2. return a null method
    By valoyivd in forum New To Java
    Replies: 2
    Last Post: 04-21-2008, 11:19 PM
  3. Replies: 2
    Last Post: 04-16-2008, 12:35 PM
  4. Simple Method Question
    By Froz3n777 in forum New To Java
    Replies: 2
    Last Post: 02-13-2008, 02:39 AM
  5. Return value of method
    By cachi in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 08:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •