About 473,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. java - Difference between size and length methods? - Stack Overflow

    Nov 25, 2013 · 103 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, …

  4. How do I declare and initialize an array in Java?

    Jul 29, 2009 · The third way of initializing is useful when you declare an array first and then initialize it, pass an array as a function argument, or return an array. The explicit type is required.

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

    To get the number of columns, we need to access the first array and consider its length. In this case, we access [1, 1, 1, 1] and thus, the number of columns = 4.

  6. Java dynamic array sizes? - Stack Overflow

    Oct 30, 2009 · In Java Array Sizes are always of Fixed Length But there is way in which you can Dynamically increase the Size of the Array at Runtime Itself This is the most "used" as well as …

  7. Why I can't create an array with large size? - Stack Overflow

    Jul 13, 2015 · Why it is impossible to create an array with max int size? int i = 2147483647; int[] array = new int[i]; I found this explanation: Java arrays are accessed via 32-bit ints, resulting in …

  8. How to find integer array size in java - Stack Overflow

    Mar 2, 2015 · 1 Integer Array doesn't contain size () or length () method. Try the below code, it'll work. ArrayList contains size () method. String contains length (). Since you have used int …

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

  10. How to determine the size of an object in Java - Stack Overflow

    Dec 17, 2019 · The java.lang.instrument.Instrumentation class provides a nice way to get the size of a Java Object, but it requires you to define a premain and run your program with a java agent.