About 51 results
Open links in new tab
  1. How to correctly compute the length of a String in Java?

    The normal model of Java string length String.length() is specified as returning the number of char values ("code units") in the String. That is the most generally useful definition of the length of a Java …

  2. arrays - length and length () in Java - Stack Overflow

    Dec 27, 2009 · Why do we have the length of an array as an attribute, array.length, and for String we have a method, str.length()? Is there some reason?

  3. java - When to use .length vs .length () - Stack Overflow

    But when you are using people[i].length(), you are accessing the string at that position of the array, and getting the length of the string, therefore using the .length() method in the String class. However, just …

  4. java - Difference between size and length methods? - Stack Overflow

    Nov 25, 2013 · size() is a method specified in java.util.Collection, which is then inherited by every data structure in the standard library. length is a field on any array (arrays are objects, you just don't see …

  5. java - Check if string length entered is equal to three - Stack Overflow

    I need to create a code that checks if the input from the user is equal to a double literal length 3. my if statement is where i am having trouble. Thanks Scanner stdIn= new Scanner(System.in); S...

  6. String's Maximum length in Java - calling length () method

    May 3, 2009 · Considering the String class' length method returns an int, the maximum length that would be returned by the method would be Integer.MAX_VALUE, which is 2^31 - 1 (or approximately 2 …

  7. java - Limiting the number of characters in a string, and chopping off ...

    You can also use String.format("%3.3s", "abcdefgh"). The first digit is the minimum length (the string will be left padded if it's shorter), the second digit is the maxiumum length and the string will be truncated …

  8. Java String array: is there a size of method? - Stack Overflow

    May 28, 2009 · I come from a php background and in php, there is an array_size() function which tells you how many elements in the array are used. Is there a similar method for a String[] array? Thanks.

  9. Java: why Array.length has no () but String.length() does?

    Jul 3, 2014 · The difference is: The length of an array is NOT about the actual content - it's the dimension! An array can be of length 10, but only contain 2 elements. An Object containing elements …

  10. How many characters can a Java String have? - Stack Overflow

    Jul 24, 2009 · Java 9 is going to use a single byte per character for strings having only iso-latin-1 content, so such strings can have as many characters as the heap in bytes (or max array length, …