About 541,000 results
Open links in new tab
  1. Java - How do I make a String array with values?

    Dec 18, 2011 · Create array from a string Hot Network Questions Is it a faux pas for a reviewer of a published math paper to immediately solve/publish problems it leaves open?

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

    Apr 1, 2010 · You can always write it like this . String[] errorSoon = {"Hello","World"}; For (int x=0;x<errorSoon.length;x++) // in this way u create a for loop that would like display the elements which are inside the array errorSoon.oh errorSoon.length is the same as errorSoon<2 { System.out.println(" "+errorSoon[x]); // this will output those two words, at the top hello and world at the bottom of hello.

  3. How do I declare and initialize an array in Java? - Stack Overflow

    Jul 29, 2009 · Static Array: Fixed size array (its size should be declared at the start and can not be changed later) Dynamic Array: No size limit is considered for this. (Pure dynamic arrays do not exist in Java. Instead, List is most encouraged.) To declare a static array of Integer, string, float, etc., use the below declaration and initialization statements.

  4. string to string array conversion in java - Stack Overflow

    To continue this train of thought, you could then convert the char array to a String array: String[] stringArray = new String[charArray.length]; for (int i = 0; i < charArray.length; i++){ stringArray[i] = String.valueOf(charArray[i]); } At this point, your stringArray will be filled with the original values from your original string "name".

  5. How to make an array of arrays in Java - Stack Overflow

    Jul 23, 2017 · @Terence: It does the same as the first: It creates an array of string array references, initialized to the values array1, array2, array3, array4 and array5 - each of which is in itself a string array reference. –

  6. Convert array of strings into a string in Java - Stack Overflow

    Apr 7, 2011 · Java 8+ Use String.join():. String str = String.join(",", arr); Note that arr can also be any Iterable (such as a list), not just an array.

  7. What's the simplest way to print a Java array? - Stack Overflow

    Since Java 5 you can use Arrays.toString(arr) or Arrays.deepToString(arr) for arrays within arrays. Note that the Object[] version calls .toString() on each object in the array.

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

    Dec 3, 2013 · The question: 3. Create a Java program called TwoDimArray and implement the following: 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 values of the 2d array using nested for loops.

  9. Java split string to array - Stack Overflow

    Jan 19, 2013 · Trailing empty strings are therefore not included in the resulting array. If you want those trailing empty strings included, you need to use String.split(String regex, int limit) with a negative value for the second parameter (limit): String[] array = values.split("\\|", -1);

  10. 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 array. Example:

Refresh