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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:08:13+00:00 2026-06-10T03:08:13+00:00

I am trying to insert a character into a string using Processing. After some

  • 0

I am trying to insert a character into a string using Processing.

After some reading around I tried out the following (I think Java) code:

1: String st = new String("abcde");
2: st = StringBuffer(st).insert(2, "C");

and got the following response:

the function StringBuffer(String) does not exist 

Is there a different/simpler way of doing this? Do I need to use StringBuffer? I’m a fairly novice programmer so any help greatly appreciated.

  • 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-10T03:08:15+00:00Added an answer on June 10, 2026 at 3:08 am

    Ok, so I’ve been looking at the processing ‘Extended Language API’ and there doesn’t seem to be some function like that out of the box.

    If you look at the String class’s substring() function, you’ll see an example where there is a String that is cut into two pieces at position 2. And then printed out with other characters between them. Will that help you any further?

    String str1 = "CCCP"; 
    String str2 = "Rabbit"; 
    String ss1 = str1.substring(2);     // Returns "CP"
    String ss2 = str2.substring(3);     // Returns "bit"
    String ss3 = str1.substring(0, 2);  // Returns "CC"
    println(ss1 + ":" + ss2 + ":" + ss3);  // Prints 'CP:bit:CC'
    

    If we take your example, this would insert the ‘C’ at the right position:

    String st = new String("abcde");
    String p1 = st.substring(0,2); // "ab"
    String p2 = st.substring(2); // "cde"
    st = p1 + "C" + p2; // which will result in "abCcde"
    

    Or create a function for it. Mind you, not super-robust (no checks for empty strings, overflow etc), but does the job:

    String insert(original, toInsert, position){
      String p1 = original.substring(0,position);
      String p2 = original.substring(position);
      return p1 + toInsert + p2;
    }
    
    ...
    
    String st = new String("abcde");
    st = insert(st, "C", 2); // "abCcde"
    st = insert(st, "D", 4); // "abCcDde"
    

    tested at http://sketch.processing.org

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

Sidebar

Related Questions

I am trying to insert a unicode hyphen-minus character into a text string. I
I'm trying to insert a comment character into a string something similar to this:
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
I am trying to insert string-values larger than 5500 characters into a MSSQL 2008
I'm trying to insert an HTML blob into our sql-server2005 database. I've been using
I am facing issue while trying into insert special symbols like pound character (£
I am trying to escape a whole string for insert into a longtext or
I am trying to insert a very long text string into a MySQL Blob
I am trying to insert a row in ms-sql table using the following code
I'm trying to insert a string that was received as an argument into a

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.