title: Returning String Methods in Java?
body: <p>I'm in a beginning programming class, and a lot of this had made sense to me up until this point, where we've started working with methods and I'm not entirely sure I understand the "static," "void," and "return" statements. </p>
  
  <p>For this assignment in particular, I thought I had it all figured out, but it says it "can not find symbol histogram" on the line in the main method, although I'm clearly returning it from another method. Anyone able to help me out?</p>
  
  <p>Assignment: "You see that you may need histograms often in writing your programs so you decide for this program to use your program 310a2 Histograms.  You may add to this program or use it as a class.  You will also write a class (or method) that will generate random number in various ranges.  You may want to have the asterisks represent different values (1, 100, or 1000 units).  You may also wish to use a character other than the asterisk such as the $ to represent the units of your graph.  Run the program sufficient number of times to illustrate the programs various abilities.</p>
  
  <p>Statements Required:  output, loop control, decision making, class (optional), methods.</p>
  
  <p>Sample Output:</p>
  
  <p>Sales for October</p>
  
  <p>Day Daily   Sales Graph</p>
  
  <p>2   37081   *************************************</p>
  
  <p>3   28355   ****************************    </p>
  
  <p>4   39158   ***************************************</p>
  
  <p>5   24904   ************************</p>
  
  <p>6   28879   ****************************</p>
  
  <p>7   13348   *************
  "</p>
  
  <p>Here's what I have: </p>
  
  <pre><code>import java.util.Random;
  
  public class prog310t
  { 
    public static int randInt(int randomNum) //determines the random value for the day
    {   
      Random rand = new Random();
  
      randomNum = rand.nextInt((40000 - 1000) + 1) + 10000;
  
      return randomNum;
    }
  
    public String histogram (int randomNum) //creates the histogram string
    {
      String histogram = "";
      int roundedRandom = (randomNum/1000);
      int ceiling = roundedRandom;
      for (int k = 1; k &lt; ceiling; k++)
      {
        histogram = histogram + "*";
      }
  
      return histogram;   
    }
  
    public void main(String[] Args)
    {
      System.out.println("Sales for October\n");
  
      System.out.println("Day        Daily          Sales Graph");
  
      for (int k = 2; k &lt; 31; k++)
      {
        if (k == 8 || k == 15 || k == 22 || k == 29)
        {
          k++;
        }
  
        System.out.print(k + "         ");
  
        int randomNum = 0;
  
        randInt(randomNum);
  
        System.out.print(randomNum + "       ");
  
        histogram (randomNum);
  
        System.out.print(histogram + "\n");
      }
    }
  }
  </code></pre>
  
  <p>Edit: Thanks to you guys, now I've figured out what static means. Now I have a new problem; the program runs, but histogram is returning as empty. Can someone help me understand why? New Code:</p>
  
  <pre><code>import java.util.Random;
  
  public class prog310t
  { 
    public static int randInt(int randomNum) //determines the random value for the day
    {   
      Random rand = new Random();
  
      randomNum = rand.nextInt((40000 - 1000) + 1) + 10000;
  
      return randomNum;
    }
  
    public static String histogram (int marketValue) //creates the histogram string
    {
      String histogram = "";
      int roundedRandom = (marketValue/1000);
      int ceiling = roundedRandom;
      for (int k = 1; k &lt; ceiling; k++)
      {
        histogram = histogram + "*";
      }
  
      return histogram;   
    }
  
    public static void main(String[] Args)
    {
      System.out.println("Sales for October\n");
  
      System.out.println("Day        Daily          Sales Graph");
  
      for (int k = 2; k &lt; 31; k++)
      {
        if (k == 8 || k == 15 || k == 22 || k == 29)
        {
          k++;
        }
  
        System.out.print(k + "         ");
  
        int randomNum = 0;
  
        int marketValue = randInt(randomNum);
  
        System.out.print(marketValue + "       ");
  
        String newHistogram = histogram (randomNum);
  
        System.out.print(newHistogram + "\n");
      }
    }
  
  
  }
  </code></pre>