About 50 results
Open links in new tab
  1. 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.

  2. How to add a method to "the array class" in Java?

    Jan 10, 2023 · The Java Arrays API does have methods that can resize arrays. If an array is made larger, zeroes are added. See public static int[] copyOf (int[] original, int newLength), for example.

  3. How do I determine whether an array contains a particular value in Java ...

    Jul 15, 2009 · If the array is sorted, you can do a binary search, there's one in the Arrays class. Generally speaking, if you are going to do a lot of membership checks, you may want to store …

  4. java - How to add new elements to an array? - Stack Overflow

    May 16, 2010 · The size of an array can't be modified. If you want a bigger array you have to instantiate a new one. A better solution would be to use an ArrayList which can grow as you need it. The …

  5. Finding the max/min value in an array of primitives using Java

    Sep 28, 2009 · If you have an array of one of those, you can find the min or max using Arrays.stream(). A comprehensive solution to the problem of reductions over primitive arrays is rather than implement …

  6. java - make arrays accessible throughout methods and classes - Stack ...

    Nov 25, 2012 · how do i make an array accessible throughout classes and methods? right now i have something similar to public class Class { public int[] array = new int[value]; public static int var; public ...

  7. Java - Creating an array of methods - Stack Overflow

    Java - Creating an array of methods Asked 15 years, 3 months ago Modified 4 years, 11 months ago Viewed 47k times

  8. Where is Java's Array indexOf? - Stack Overflow

    Feb 10, 2011 · If your array is not sorted and not primitive type, you can use List's indexOf and lastIndexOf methods by invoking the asList method of java.util.Arrays. This method will return an …

  9. pass array to method Java - Stack Overflow

    Oct 23, 2009 · Important Points you have to use java.util package array can be passed by reference In the method calling statement Don't use any object to pass an array only the array's name is used, …

  10. java - Accessing an array in another method - Stack Overflow

    Apr 10, 2015 · Here the array is created in the method, and is passed explicitly as a parameter to the initialization and printing methods. Note that the methods are marked , and accessed without …