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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:12:50+00:00 2026-06-05T23:12:50+00:00

There is a String variable containing ascii characters and double bytes characters(for example, the

  • 0

There is a String variable containing ascii characters and double bytes characters(for example, the Chinese, Japanese,…).

How to decide the total length of the String ? Also, I want to implement with the string substring/replace function.

  • 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-05T23:12:51+00:00Added an answer on June 5, 2026 at 11:12 pm

    As other’s have said, Java Strings are conceptually read-only arrays of Java characters, and the “length” of a String is the number of characters. However, there are complicating issues:

    • A Java character is not necessarily what you think of as a character. In particular, there are more Unicode characters (code-points) than can be represented using Java characters. Some Unicode code-points require two Java characters to represent them. (This is the “extended plane” issue that Thilo refers to.)

    • Some JVMs (with the appropriate JVM flags set at startup) will use a String representation where the characters are encoded in UTF-8. While the length of the String is the same (in this case, the number of Java characters represented by the UTF-8), the memory used can be significantly less.

    Then there is the question of how many bytes are required to represent the String’s characters as UTF-8, or in some other encoding. As far as I know, the only JVM provided way to find that out is to do the conversion; e.g. using getBytes(charSet).

    Finally, there is the question of how many bytes a String occupies in the heap. You can find out how many bytes are in the String object and its associated char[] backing object. However, predicting what that is going to be can be tricky, when you consider that substring and other String methods can create sets of strings that share a single backing array.

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

Sidebar

Related Questions

If I have a variable containing a string, is there a way that I
I have a string variable, containing XML data and I was wondering if there
Is there a way to insert a string in a string constant/variable that contains
Given a variable which holds a string is there a quick way to cast
Is there a way to refer to a Javascript variable with a string that
Is there any way how to express a variable in PostgreSQL as a string?
I am looking for a way to create a string variable containing certain values
I have a variable containing a string from which I want to parse the
I have a string containing an environment variable, e.g. my_path = '$HOME/dir/dir2' I want
I have a variable in javascript containing a string of XML data that I

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.