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

    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 initialize an array in Java? - Stack Overflow

    Dec 21, 2009 · Notice the difference between the two declarations. When assigning a new array to a declared variable, new must be used. Even if you correct the syntax, accessing data[10] is still …

  3. Java: how to initialize String []? - Stack Overflow

    9 I believe you just migrated from C++, Well in java you have to initialize a data type (other then primitive types and String is not a considered as a primitive type in java ) to use them as according to their …

  4. java - Any way to declare an array in-line? - Stack Overflow

    Feb 28, 2016 · 38 You can directly write the array in modern Java, without an initializer. Your example is now valid. It is generally best to name the parameter anyway.

  5. java - Array Instantiation - Stack Overflow

    Dec 31, 2009 · Can you help me out with this question please. Question: Given the following array declarations double readings[]; String urls[]; TicketMachine[] machines; write assignments that …

  6. How to initialize an array of objects in Java - Stack Overflow

    I want to initialize an array of Player objects for a BlackJack game. I've read a lot about various ways to initialize primitive objects like an array of ints or an array of strings but I cannot ta...

  7. java - How to declare and instantiate a new Generic array ... - Stack ...

    Feb 21, 2013 · Type mismatch: cannot convert from Array to T []. I don't understand what I'm missing or doing wrong. So to sum up my question, how do you declare and instantiate a new generic array, …

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

    As a rule of thumb, this behavior is safe as long as the cast array is used internally (e.g. to back a data structure), and not returned or exposed to client code. Should you need to return an array of a …

  9. Double array initialization in Java - Stack Overflow

    I was reading a book on Java and came across an example in which an array of type double was initialized in a way that I haven't seen before. What type of initialization is it and where else can it...

  10. How to instantiate a Java array given an array type at runtime?

    May 18, 2013 · If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection. If you wanted to …