Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8896957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:12:30+00:00 2026-06-15T00:12:30+00:00

I need to return finalString value for input operator name. where,internalPrestring is fixed for

  • 0

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

 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 < 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);

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:12:31+00:00Added an answer on June 15, 2026 at 12:12 am

    You are having only four lines that deals with your CallManager class:

    CallManager clm = new CallManager();
    clm.setOperatorName("Banglalink");
    System.out.println(clm.internalPreString);
    System.out.println(clm.preString);
    

    The reason why you are getting null :

    1. You are using a default constructor right and there processing is
      done in it. So this is not a problem
    2. Now on next line you call setOperator method which has this code:

      public void setOperatorName( String getMeFromPreferences)  
      {  
         operatorName = getMeFromPreferences;  
         System.out.println("I got it " + operatorName);  
      }
      

      Now here you are only setting thw variable operatorName and nothing else. So all other variables are null as you not doing any processing or something that will initialize them to something.

    3. So when you print clm.internalPreString and clm.preString you get null as they are not initialized. But try printing clm.operatorName and it will print the operator name that you passed and was initialzed inside your method setOperatorName.

    So as you have defined so many method inside your class, use them so that all the variables are set as per your logic

    UPDATE

    public void setOperatorName( String getMeFromPreferences)  
    {  
         operatorName = getMeFromPreferences;  
    
         //call any methods for example and use the values returned from the method by storing it inside a variable 
         String mystring = getOperatorBasedPreString(String operatorName) 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to return a full directory name from inside a specified directory that
i need to return a JSON with this format: {answers: [{id: 93, value:Ahstron}, {id=94,
I need to return server time from a webservice. I've got the following code:
I need to return multiple values from a ColdFusion function in an ajax callback
I have need to return multiple results from a subquery and have been unable
I need to store a load of content which I retrieved from http. I
I need to return an a generic list in the correct order for my
I need to return a list of counties, but I need to filter out
I need to return a string in the form xxx-xxxx where xxx is a
I need to return two values at a time, so I have: class IterableObject(object):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.