About 145,000 results
Open links in new tab
  1. How can I get the size of an array, a Collection, or a String in Java?

    May 19, 2014 · What are the different ways that I can access the length of an array, a collection (List, Set, etc.), and a String object? Why is it different?

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

    Dec 27, 2009 · In Java, an Array stores its length separately from the structure that actually holds the data. When you create an Array, you specify its length, and that becomes a defining …

  3. Resize an Array while keeping current elements in Java?

    82 I have searched for a way to resize an array in Java, but I could not find ways of resizing the array while keeping the current elements. I found for example code like int[] newImage = new …

  4. java - Length of byte [] array - Stack Overflow

    Mar 12, 2014 · String str = "123456789"; byte[] bytes = str.getBytes(); I want to make the following loop for (int j = 0; j < bytes.length(); j++) { b = bytes[j]; } b will store each byte of my array, but I …

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

  6. Do Java arrays have a maximum size? - Stack Overflow

    Jun 14, 2010 · Java uses an integer as an index to the array and the maximum integer store by JVM is 2^32. so you can store 2,147,483,647 elements in the array. In case you need more …

  7. Getting the array length of a 2D array in Java - Stack Overflow

    I need to get the length of a 2D array for both the row and column. I’ve successfully done this, using the following code: public class MyClass { public static void main (String args []) { ...

  8. Java dynamic array sizes? - Stack Overflow

    Oct 30, 2009 · 1 Java Array sizes are fixed , You cannot make dynamic Arrays as that of in C++.

  9. Java: how do I initialize an array size if it's unknown?

    Apr 3, 2013 · You should use a List for something like this, not an array. As a general rule of thumb, when you don't know how many elements you will add to an array before hand, use a …

  10. Declare an array in java without size - Stack Overflow

    Hello am trying to declare an array in java but i do not want the array to have a specific size because each time the size must be different. I used this declaration: int[] myarray5; but when...