title: How to get rid of that pesky leading plus sign?
body: <p>I have a code that basically reads from a text file. There is a leading plus sign when it outputs because the answer is printed in a loop. How do I get rid of that singular leading plus sign? All I can think to do is to convert the ENTIRE THING to a string and then take out the first three indexes but that's way too complicated. Is there a simple way to just rearrange the logic and do it?</p>
  
  <p>My code:</p>
  
  <pre><code>    /*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  package importtextfiles;
  
  /**
   *
   * @author Hana
   */
  import java.io.*;
  import java.util.*;
  public class InputNumData {
      public static void main(String args[]) throws IOException
      {
          Scanner sf = new Scanner(new File("C:\\Users\\Hana\\SkyDrive\\CompSci\\Programming\\importTextFiles\\meow.txt"));
          int maxIndx = -1; //so the first index is 0
  
          String text[] = new String[1000];
  
          while(sf.hasNext()){
              maxIndx++;
              text[maxIndx] = sf.nextLine();
              System.out.println(text[maxIndx]);
          }
  
          sf.close();
  
          String answer = "";
          int sum;
  
          for(int j=0; j&lt;=maxIndx; j++){
              Scanner sc = new Scanner(text[j]);
              sum = 0;
              answer = "";
  
              while(sc.hasNext()){
                  int i = sc.nextInt();
                  answer = answer + " + " + i;
                  sum = sum + i;
              }
              answer = answer + " = " + sum;
              System.out.println(answer);
          }
      }
  }
  </code></pre>
  
  <p>My output:</p>
  
  <pre><code>run:
  12 10 3 5
  18 1 5 92 6 8
  2 9 3 22 4 11 7
   + 12 + 10 + 3 + 5 = 30
   + 18 + 1 + 5 + 92 + 6 + 8 = 130
   + 2 + 9 + 3 + 22 + 4 + 11 + 7 = 58
  BUILD SUCCESSFUL (total time: 0 seconds)
  </code></pre>
  
  <p>meow.txt:</p>
  
  <pre><code>12 10 3 5
  18 1 5 92 6 8
  2 9 3 22 4 11 7
  </code></pre>