About 50 results
Open links in new tab
  1. Java: how to initialize String []? - Stack Overflow

    String[] errorSoon; // <--declared statement String[] errorSoon = new String[100]; // <--initialized statement You need to initialize the array so it can allocate the correct memory storage for the String …

  2. Java - How do I make a String array with values? - Stack Overflow

    Dec 18, 2011 · I know how to make an empty array, but how do I make a String array with values from the start?

  3. How to create and initialise in Java an array of String arrays in one ...

    Aug 17, 2022 · (String[])[] = {emptyArr, filledArr, moreFilledArr}; With the brackets in the second version I want to indicate that the array is one of string arrays and not a two-dimensional array.

  4. Java - Create String Array from text file - Stack Overflow

    1 Based on your input you are almost there. You missed the point in your loop where to keep each line read from the file. As you don't a priori know the total lines in the file, use a collection (dynamically …

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

  6. How to declare string array [] of unknown size (JAVA)

    Aug 30, 2016 · Arrays have a fixed size which must be known when the array is created. If you need something to hold a variable number of elements, use a collection class such as ArrayList instead.

  7. How to create, populate, and print a string array in Java

    How to create, populate, and print a string array in Java Asked 12 years, 4 months ago Modified 4 years ago Viewed 26k times

  8. java - add string to String array - Stack Overflow

    Dec 31, 2012 · Since Java arrays hold a fixed number of values, you need to create a new array with a length of 5 in this case. A better solution would be to use an ArrayList and simply add strings to the …

  9. java - Create a two dimensional string array anArray [2] [2] - Stack ...

    Dec 3, 2013 · Create a two dimensional string array anArray[2][2]. Assign values to the 2d array containing any Country and associated colour. Example: France Blue Ireland Green Output the …

  10. Java Byte Array to String to Byte Array - Stack Overflow

    As with other respondents, I would point you to the String constructors that accept a byte[] parameter to construct a string from the contents of a byte array. You should be able to read raw bytes from a …