title: java,returning null value from method
body: <p>I need to return finalString value for input operator name.
  where,internalPrestring is fixed for specific operator,internalDigit would be retrieved from getting operator name.then all of'em would be added to finalString.
  but it is giving null, i can't understand the problem</p>
  
  <pre><code> import java.io.*;
   import java.lang.*;
  
   class CallManager
   {
  
  
     public static final String postString = "#";
  
     StringBuilder stringBuilder;
  
     String internalPreString;
     String preString;
     String middleString;
     String finalString;
     String operatorName;
  
  
     int internalDigit;
  
  
  
     //needs to set oprator name
     public void setOperatorName( String getMeFromPreferences)
     {
  
      operatorName = getMeFromPreferences;
          System.out.println("I got it " + operatorName);
     }
  
  
  //afeter having operator name need to set inrernal digit for each operator
  public void setOperatorBasedInternalDigit(int getIntegerForOperator)
      {
          internalDigit = getIntegerForOperator;
          System.out.println("I got it too " + internalDigit);
      }
  
  //it needs to get string from ocr  
  public void setString( String getMeFromOCR )
      {
          middleString = getMeFromOCR;
      }
  
  
  //preString creator for differnet operator
  public String getOperatorBasedPreString(String operatorName)
  {
          if(operatorName.equals("Airtel"))
          internalPreString = "787";
  
          else if(operatorName.equals("Banglalink"))
          internalPreString = "123";
  
          else if(operatorName.equals("Grameen"))
          internalPreString = "555";
  
          else if(operatorName.equals("Robi"))
          internalPreString = "111";
  
          else if(operatorName.equals("TeleTalk"))
          internalPreString = "151";
  
  
          stringBuilder.append("*").append(internalPreString).append("*");
          preString = stringBuilder.toString();
  
          return preString;
  
  }
  
  //get operator name and retrive midlle string's digit size from it
  public int getOperatorBasedInternalDigit( String operatorName)
  {
  
          if(operatorName.matches("^Airtel | Grameen | Robi$"))
          internalDigit = 16; 
  
          else if(operatorName.matches("^Banglalink$"))
          internalDigit = 14;
  
          else if(operatorName.matches("^TeleTalk$"))
          internalDigit = 13;
  
  
          return internalDigit;
  }
  
  //check operator-based digit number with input middle string as a number then retrive final string
  public String getString( String toBeInserted, int inetrnalDigit)
      {
  
          if(toBeInserted.length() == internalDigit)
          {
  
              int counter = 0;
              char [] insertHere  = new char[internalDigit];
  
              for(int verifier = 0; verifier &lt; internalDigit; verifier ++)
              {
                  insertHere[verifier] = toBeInserted.charAt(verifier);
                      if(!Character.isDigit(insertHere[verifier]))
                      break;
  
              counter ++;
              }
  
              if(counter == internalDigit)
              {
  
                      stringBuilder.append(preString).append(toBeInserted).append(postString);
                      finalString = stringBuilder.toString();
                      //to see what i've got finally as input for using this call manager method.it would be removed too
                      System.out.println(finalString);
                      return finalString;
              }
  
              else
              {
                  //this printing could be used in main program
                  System.out.println("number is less or more than desired ..... INVALID SCAN");
                  System.out.println(middleString);
                  //here i will call the method for scan the card again
                  //
                  //
                     return middleString;
               }
            }
  
  
            else
                {
                  //this printing could be used in main program
                  System.out.println("number is less or more than desired ..... INVALID SCAN");
                  System.out.println(middleString);
                  //here i will call the method for scan the card again
                  //
                  //
                  return middleString;
                }
  
  
  
      }
  
  
  }
  
  
  //tester class that CallManager works rightly or not
  class CallManagerDemo
  {
      public static void main(String args[]) throws IOException
      {
              BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  
  
  
            System.out.println("Enter name of Operator");
            CallManager clm = new CallManager();
  
            clm.setOperatorName("Banglalink");
            System.out.println(clm.internalPreString);
            System.out.println(clm.preString);
  
      }
  }
  </code></pre>