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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:28:28+00:00 2026-06-07T22:28:28+00:00

Java seems to have very good string handling. Still, I’m having problems with the

  • 0

Java seems to have very good string handling. Still, I’m having problems with the simplest of problems. I need to have dynamic strings (they change at run time) so a String type is not a good choice since they are immutable. So I am using char arrays. Kind of a pain to setup but at least they are modifiable. I want to create a string constant with a carriage return/line feed pair in it (or other control characters). In C/C++ you would just do this:

char myString[100];
myString = "This is a string with a CR/LF pair\x0D\x0A";

And yes, I know in java you could use a “\r”. And yes, I know that you could use:

myString[34] = 0x000D;
myString[35] = 0x000A;

And in Java you really cannot use a string literal constant to initialize a char array (can you??). So how do you initialize a char array is the question?

  • 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-07T22:28:30+00:00Added an answer on June 7, 2026 at 10:28 pm

    You can do

    char[] myString = 
       "This is a string with a CR/LF pair\u000D\u000A".toCharArray();
    

    if that was the question.

    Also, there is StringBuilder to work with mutable Strings (it just wraps a char[]).

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

Sidebar

Related Questions

I noticed that the launching of Java applets using deployJava.js seems to have stopped
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
It seems the java.net.NetworkInterface implementation of android does not have a byte[] getHardwareAddress() method
Why does Java not have a file copy method? This seems like such an
I have to admit that I'm new to Java and Android. db4o seems to
I’m not sure how to use Java/JDBC to insert a very long string into
I have problems with moving files in directories in Java. The problem is that
I have a very simple Java application which downloads a set of foreign exchanges
I have someone I need to train in Java. That person is well versed
I have a Java applet that uses the HTTPURLConnection class to upload very large

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.