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

  • Home
  • SEARCH
  • 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 8544657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:36:49+00:00 2026-06-11T12:36:49+00:00

The programme below is trying to take a single text from the first edit

  • 0

The programme below is trying to take a single text from the first edit box and match the word vysh and produce the output in the second editbox .The second edit box has dots initially and if each word matches the word VYSH then it replaces the dots .

I get an error while running the programme and the error is the following:

09-14 19:47:25.593: D/AndroidRuntime(469): Shutting down VM
09-14 19:47:25.593: W/dalvikvm(469): threadid=1: thread exiting with uncaught exception (group=0x40014760)
09-14 19:47:25.593: E/AndroidRuntime(469): FATAL EXCEPTION: main
09-14 19:47:25.593: E/AndroidRuntime(469): java.lang.NullPointerException
09-14 19:47:25.593: E/AndroidRuntime(469):  at java.lang.String.<init>(String.java:505)
09-14 19:47:25.593: E/AndroidRuntime(469):  at com.example.testinput.MainActivity$1.onClick(MainActivity.java:46)
09-14 19:47:25.593: E/AndroidRuntime(469):  at android.view.View.performClick(View.java:3110)
09-14 19:47:25.593: E/AndroidRuntime(469):  at android.view.View$PerformClick.run(View.java:11934)
09-14 19:47:25.593: E/AndroidRuntime(469):  at android.os.Handler.handleCallback(Handler.java:587)
09-14 19:47:25.593: E/AndroidRuntime(469):  at android.os.Handler.dispatchMessage(Handler.java:92)
09-14 19:47:25.593: E/AndroidRuntime(469):  at android.os.Looper.loop(Looper.java:132)
09-14 19:47:25.593: E/AndroidRuntime(469):  at android.app.ActivityThread.main(ActivityThread.java:4123)
09-14 19:47:25.593: E/AndroidRuntime(469):  at java.lang.reflect.Method.invokeNative(Native Method)
09-14 19:47:25.593: E/AndroidRuntime(469):  at java.lang.reflect.Method.invoke(Method.java:491)
09-14 19:47:25.593: E/AndroidRuntime(469):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
09-14 19:47:25.593: E/AndroidRuntime(469):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
09-14 19:47:25.593: E/AndroidRuntime(469):  at dalvik.system.NativeStart.main(Native Method)
09-14 19:47:30.175: I/Process(469): Sending signal. PID: 469 SIG: 9

The program is shown below:

package com.example.testinput;

public class MainActivity extends Activity {

String rword="vysh";
private StringBuffer gword=new StringBuffer();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    Button button=(Button) findViewById(R.id.button1);

    final EditText output=(EditText) findViewById(R.id.editText2);
  //input dots in edittext
    char positions[] = new char[rword.length()];
    for (int i=0; i<rword.length(); i++) {
        positions[i] = '.';

}
    String dots=new String(positions);
    output.setText(dots);
    //end of input dots

    button.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            EditText text=(EditText)findViewById(R.id.editText1);
                            String str="";

            str=text.getText().toString();
            if(!TextUtils.isEmpty(str))
            {           
            //String t=new String(gword);
            char a=str.charAt(0);
            //replace dots with text 
            for (int i=0; i<rword.length(); i++)
            {
                if((rword.charAt(i))==a)
                {
                    gword.setCharAt( i, a);
                }

            }
            //print the output
            output.setText(gword);
            }end of iftextutils         
        }
    }); 
     }

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;}

}

Tried initializing stringbuffer and edited the program based on below solutioons but the program doesn’t work…I get the following error:09-17 10:48:11.169: 09-17 11:36:03.439: E/AndroidRuntime(926): java.lang.StringIndexOutOfBoundsException: index=0 length=0
09-17 11:36:03.439: E/AndroidRuntime(926): at java.lang.AbstractStringBuilder.indexAndLength(AbstractStringBuilder.java:214)
09-17 11:36:03.439: E/AndroidRuntime(926): at java.lang.AbstractStringBuilder.setCharAt(AbstractStringBuilder.java:544)
09-17 11:36:03.439: E/AndroidRuntime(926): at java.lang.StringBuffer.setCharAt(StringBuffer.java:698)
09-17 11:36:03.439: E/AndroidRuntime(926): at com.example.testinput.MainActivity$1.onClick(MainActivity.java:60)
09-17 11:36:03.439: E/AndroidRuntime(926): at android.view.View.performClick(View.java:3110)

It shows there is an error at String.charat function ..Basically i want to replace the dots in the editbox to characters in the first box if it matches the word vysh.

  • 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-11T12:36:50+00:00Added an answer on June 11, 2026 at 12:36 pm

    In the line String t=new String(gword);, the variable gword is null, which causes the Exception. As far as I can see, you’re not using t anyways, so … remove the line, or create t with a simple new String().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The below program is used to take the input of integers from a text
I'm trying to write my first semi advanced bash script that will take input
Edit: I decided to take the LINQ to XML approach (see the answer below)
I am trying to create a program that will take user inputs(marks) and output
New programmer here, I am trying to understand and break down this code below
(In short: main()'s WaitForSingleObject hangs in the program below). I'm trying to write a
Below is my program and I am trying to get the call stack when
I have a C program like the one below. I am trying to write
The two programs below get n integers from file and calculates the sum of
Below program contains two show() functions in parent and child classes, but first show()

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.