Number of Characters in Java String

0 votes

I was working on a code where I am supposed to find the palindrome for an integer of up to a million digits. To make my task easy, I was thinking of using the String reverse function. But I have a doubt regarding the max length of the String that Java allows. Have anyone any idea regarding this?

Oct 22, 2018 in Java by 93.lynn
• 1,600 points
41 views

1 answer to this question.

0 votes

I think you can make use of either of the following to know the max length of String you can use:

  1. Integer.MAX_VALUE (always 2147483647 (231 - 1).​
  2. Half of your maximum heap size as each character is two bytes
answered Oct 22, 2018 by anto.trigg4
• 3,440 points

Related Questions In Java

0 votes
2 answers

What is the easiest way to iterate through the characters of a string in Java?

There are two approaches to this: for(int i ...READ MORE

answered Aug 19, 2019 in Java by Sirajul
• 48,810 points
141 views
0 votes
3 answers

How can I separate the digits of an int number in Java?

import java.util.*; public class AmstrongNumber { public static void ...READ MORE

answered Aug 6, 2019 in Java by anonymous
11,516 views
0 votes
1 answer

Purpose of “String args[]” in the “psvm” of Java

Let me give you the complete explanation ...READ MORE

answered May 7, 2018 in Java by code.reaper12
• 3,470 points
151 views
0 votes
2 answers

Get all the permutations of a string in Java

You could use recursion to do this.  Try ...READ MORE

answered Aug 21, 2019 in Java by Sirajul
• 48,810 points
161 views
0 votes
3 answers

Check if a String is numeric in Java

Java 8 Lambda Expression is used: String someString ...READ MORE

answered Sep 3, 2018 in Java by Daisy
• 8,090 points
1,121 views
0 votes
2 answers

Generate an alpha-numeric string randomly

Java supplies a way of doing this ...READ MORE

answered Jul 18, 2018 in Java by Daisy
• 8,090 points
571 views
0 votes
1 answer

How do I create a Java string from the contents of a file?

If you're looking for an alternative that ...READ MORE

answered Apr 19, 2018 in Java by Rishabh
• 3,560 points
145 views
0 votes
2 answers

Counting no of Occurrence of a particular character inside a string in Java

We can find out the no. of ...READ MORE

answered Sep 7, 2018 in Java by Sushmita
• 6,890 points
466 views
+1 vote
2 answers

Retrieve all the implementations of an interface in Java

Take a look here: https://github.com/burningwave/core/wiki/USE- ...READ MORE

answered Dec 20, 2019 in Java by Roberto
• 300 points

edited Dec 31, 2019 by Roberto 2,908 views
0 votes
1 answer

Setting time zone of a java.util.Date

You can make use of the following ...READ MORE

answered Aug 14, 2018 in Java by anto.trigg4
• 3,440 points
6,352 views