About 524,000 results
Open links in new tab
  1. How do I declare and initialize an array in Java? - Stack Overflow

    Jul 29, 2009 · This answer fails to properly address the question: "How do I declare and initialize an array in Java?" Other answers here show that it is simple to initialize float and int arrays when they …

  2. When to use a List over an Array in Java? - Stack Overflow

    Oct 19, 2009 · There are almost no good reason to use an array instead of List. The main exception being the primitive array (like int[]). You cannot create a primitive list (must have List<Integer>). The …

  3. How to use java.util.Arrays - Stack Overflow

    Apr 6, 2011 · I think what you are trying to ask is how to use Arrays in java. In which case you don't import java.util.Arrays, you use the array syntax.

  4. Arrays.fill with multidimensional array in Java - Stack Overflow

    Aug 19, 2011 · In fact, Java has no true multidimensional arrays. As it happens, 0.0 is the default value for doubles in Java, thus the matrix will actually already be filled with zeros when you get it from . …

  5. How do I fill arrays in Java? - Stack Overflow

    Feb 23, 2009 · 2 Array elements in Java are initialized to default values when created. For numbers this means they are initialized to 0, for references they are null and for booleans they are false. To fill the …

  6. Use an array as a case statement in switch - Stack Overflow

    Dec 18, 2013 · I am trying to do something like this, i.e., use an array in a switch statement. Is it possible in Java? If it isn't, please explain a possible solution. boolean[] values = new boolean[4]; values...

  7. java - Make copy of an array - Stack Overflow

    Arrays.copyOf (): If you want to copy first few elements of an array or full copy of array, you can use this method. Obviously it’s not versatile like System.arraycopy () but it’s also not confusing and easy to use.

  8. How can I create a generic array in Java? - Stack Overflow

    In Java 8, we can do a kind of generic array creation using a lambda or method reference. This is similar to the reflective approach (which passes a Class), but here we aren't using reflection.

  9. java Arrays.sort 2d array - Stack Overflow

    176 Use Overloaded Arrays#Sort (T [] a, Comparator c) which takes Comparator as the second argument.

  10. java - How to use an Array with an If statement - Stack Overflow

    May 15, 2013 · I am new to Java. I'm not really sure how to effectively use an array in Java. I may not be able to use the correct terms so I will attempt to show you in code. Basically, this is my array. int[]