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 930181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:17:38+00:00 2026-05-15T20:17:38+00:00

someString[someRandomIdx] = ‘g’; will give me an error. How do I achieve the above?

  • 0
someString[someRandomIdx] = 'g';

will give me an error.

How do I achieve the above?

  • 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-05-15T20:17:39+00:00Added an answer on May 15, 2026 at 8:17 pm

    If it is of type string then you can’t do that because strings are immutable – they cannot be changed once they are set.

    To achieve what you desire, you can use a StringBuilder

    StringBuilder someString = new StringBuilder("someString");
    
    someString[4] = 'g';
    

    Update

    Why use a string, instead of a StringBuilder? For lots of reasons. Here are some I can think of:

    • Accessing the value of a string is faster.
    • strings can be interned (this doesn’t always happen), so that if you create a string with the same value then no extra memory is used.
    • strings are immutable, so they work better in hash based collections and they are inherently thread safe.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I can tell new Double(someString) and Double.parseDouble(someString) give me the exact
In python, are strings mutable? The line someString[3] = a throws the error TypeError:
There are static html files called blahblah.html?somestring . I'm always get 404 error. When
var somestring = mary(3) apple(2) sky(1); $(#removelaststring).unbind(click).bind(click,function(e){ somestring = somestring.replace(/\(\d+\)*$/, ) alert(somestring); }); i
string str1(someString); string str2 = string(str1);//how many copies are made here //copy2 = copy1?
If we have char *val = someString; and then say if(val){ .... } what
I have a table like this: someid somestring 1 Hello 1 World 1 Blah
I have this string: var someString = 23/03/2012; and want to replace all the
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
I have the code: unsigned int length = strlen(somestring); I'm compiling with the warning

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.