title: Java: Using Static Methods for repeated code sections
body: <p>So I'm learning Java (<em>gasp</em> bet you could've never guessed that), and today I'm focused heavily on making sure that I'm using static methods properly.</p>
  
  <p>My big practice program right now is an account manager program, that I tweak and add to as I learn more and more concepts. One component of it is printing out a list of all the accounts added to the system. Because this list gets summoned more than once, I created a static method that can be invoked to generate it, and placed it above my main method in the code.</p>
  
  <p>My question is: should I do this? Is it a good idea/good programming etiquette to create methods like this for repetitive sections of code? And if the answer to both of those is yes, should I make it a static method?</p>
  
  <p>Here's the code for the static method I'm talking about:</p>
  
  <pre><code>/**
   * accountList() method displays a list of all accounts currently loaded into the program
   */
  public static void accountList(){
      System.out.println("     ACCOUNT LIST");
      System.out.println("NUMBER      INFORMATION");
      for(int num = 0; num &lt; accountArray.size(); num++){
          System.out.println("  " + (num + 1) + "         " + accountArray.get(num).getAccountName()
                           + " : " + moneyFormat.format(accountArray.get(num).getValue()) + " "
                           + accountArray.get(num).getCurrencyType());
      }
      listMax = accountArray.size();
  }
  </code></pre>
  
  <p>Then below this would be my main() method, and periodically within my main would be the invocation of this method to generate an account list:</p>
  
  <pre><code>public static void main(String[] args){
      accountList(); //example of how I would invoke this method
  }
  </code></pre>
  
  <p>So, do I have this figured out properly? Am I using this correctly? Thanks.</p>
  
  <p>PS. My accountList() method is in the same class as my main() method, which is why there's no class name before it. That's also why I'm asking, because I know one of the main purposes of the term "static" is that it would be easily accessible from another class, so I'm not sure if it needs to be static if it's in this same class.</p>