title: This method must return a result of type String, Java
body: <p>I'm pretty new to Java. Eclipse is giving me the error</p>
  
  <p>This method must return a result of type</p>
  
  <p>I want to return the String str, if I put str after all the for-loops I would get local variable not initialized. How could I code it so that </p>
  
  <pre><code>public String getQuadraticFactors() {
  
      String str;
  
      ArrayList&lt;Integer&gt; prFactors = new ArrayList&lt;Integer&gt;();
  
      ArrayList&lt;Integer&gt; qsFactors = new ArrayList&lt;Integer&gt;();
  
      ArrayList&lt;Integer&gt; p = getPRIntegerFactors(a), r = getPRIntegerFactors(a), q = getQSIntegerFactors(c),
              s = getQSIntegerFactors(c);
  
      System.out.println(p + "*********" + q);
  
  
      System.out.println(p.get(0));
      // String str2 = "jjjhljl";
      String str2 = "(" + p + "x + " + q + ")(" + r + "x +" + s + ")";
  
  
  
      for (int k = 0; k &lt; p.size(); k++) {
          // System.out.print(k);
          for (int l = 0; l &lt; q.size(); l++) {
              // System.out.print(k);
              for (int m = 0; m &lt; p.size(); m++) {
  
                  for (int n = 0; n &lt; q.size(); n++) {
  
                      if (p.get(k) * r.get(m) == a &amp;&amp; p.get(k) * s.get(n) + q.get(l) * r.get(m) == b
                              &amp;&amp; q.get(l) * s.get(n) == c) {
  
                          System.out.println(a);
                          System.out.println(p.get(k) * r.get(m));
                          return str = "(" + p.get(k) + "x + " + q.get(l) + ")(" + r.get(m) + "x + " + s.get(n) + ")";    
  
  
                      }
  
  
                  }
  
              }
          }
  
      }
  
  }
  </code></pre>