About 53 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 …

  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 - 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 …

  4. 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 …

  5. 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 …

  6. java - Check if string length entered is equal to three - Stack …

    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); …

  7. java - Why is String.length () a method? - Stack Overflow

    Jan 3, 2012 · The String class was probably one of the very first classes defined for Java, ever. It's possible (and this is just speculation) that the implementation used a .length() method …

  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[] …

  9. java - Limiting the number of characters in a string, and chopping …

    1248 diffe 22.348 montre I am thinking I need to do something in the constructor that forces a string not to exceed a certain number of characters. I will probably cast the doubles and ints to …

  10. 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 …