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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:29:35+00:00 2026-05-23T16:29:35+00:00

I’m currently working on a project for a class to create a TextLine class

  • 0

I’m currently working on a project for a class to create a TextLine class that represents the a line of text that must be represented as an array of characters.

For one of the methods, I am supposed to take in a string as an argument of a parameter and then append that string to my already created char array.

I was trying to search online for how I could do this, or even an example of the String or StringBuffer class that showed the implementation, but due to my novice skills at Google, I couldn’t really find anything useful.

What I ‘m thinking is that I first have to convert the string to the array, and then somehow using one of the array methods to add each char individually to the char array.

This is what I have:

public void append(String fragment){

    char[] temp = fragment.toCharArray();

}

I’m not quite sure what array method could be used, if there even is one. Could someone please help me?

  • 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-23T16:29:36+00:00Added an answer on May 23, 2026 at 4:29 pm

    Normally you would use a StringBuilder as the internal storage for your class but i assume that you need the basic details of how to do this.

    The basic process is like this:

    • allocate a new array with the size of old array + size of the new data
    • copy the old data into the new array
    • copy the new data at the end of the new array
    • set this as the actual data

    Here is the code (this assumes that the data member is declared like this: char[] data = new char[0]:

        public void append(String fragment) {
           char[] fragmentChars = fragment.toCharArray();
           char[] newData = new char[data.length + fragmentChars.length];
    
           System.arraycopy(data, 0, newData, 0, data.length);
           System.arraycopy(fragmentChars, 0, newData, data.length, fragmentChars.length);
    
           data = newData;
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has

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.