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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:06:07+00:00 2026-06-10T09:06:07+00:00

Possible Duplicate: String's Maximum length in Java – calling length() method I have a

  • 0

Possible Duplicate:
String's Maximum length in Java – calling length() method

I have a string defined as

String xx

Is there any limit for the number of characters that I can assign?

2) I am assigning the user input to this string xx.
70% of the times people give only one word. some times they give a big sentence so want to know is that ok? or is there any better java practices?

  • 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-10T09:06:08+00:00Added an answer on June 10, 2026 at 9:06 am

    A common question you could have searched for but I going to answer it again anyway.

    Is there any limit for the number of characters that I can assign?

    Its Integer.MAX_VALUE or 2^31-1 or about 2 billion. You are more likely to have memory problems before getting to this size. e.g. You need 4 GB for the String and 4 GB to create it.

    I am assigning the user input to this string xx. 70% of the times people give only one word. some times they give a big sentence so want to know is that ok?

    I suspect all the works of J K Rowling would fit into one string.

    or is there any better java practices?

    I suggest you keep things as simple as possible. Assigning a String reference is about simple as it gets.

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

Sidebar

Related Questions

Possible Duplicate: Maximum length of a std::basic_string<_CharT> string I would like to know how
Possible Duplicate: Differences in string compare methods in C# Is there any difference between
Possible Duplicate: Java string comparison? I have encounter the following problem, I have an
Possible Duplicate: how many characters can a Java string have? How many characters can
Possible Duplicate: Split string to equal length substrings in Java Given the following utility
Possible Duplicate: String with array structure to Array I have an array as such
Possible Duplicate: Java String.equals versus == I know it' a dumb question but why
Possible Duplicate: remove duplicate from string in PHP Have a string like: $str =
Possible Duplicate: String vs string in C# I know there is no difference between
Possible Duplicate: String concatenation vs String Builder. Performance Any difference (performance and memory usage)

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.