Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

join array java

String joinedString = String.join(", ", strArray);
Comment

java join array


String.join(delimiter, elements);

Comment

join arrays in java

// Java Program to demonstrate merging
// two array using pre-defined method
  
import java.util.Arrays;
  
public class MergeTwoArrays1 {
    public static void main(String[] args)
    {
        // first array
        int[] a = { 10, 20, 30, 40 };
  
        // second array
        int[] b = { 50, 60, 70, 80 };
  
        // determines length of firstArray
        int a1 = a.length;
        
        // determines length of secondArray
        int b1 = b.length;
        
        // resultant array size
        int c1 = a1 + b1;
  
        // create the resultant array
        int[] c = new int[c1];
  
        // using the pre-defined function arraycopy
        System.arraycopy(a, 0, c, 0, a1);
        System.arraycopy(b, 0, c, a1, b1);
  
        // prints the resultant array
        System.out.println(Arrays.toString(c));
    }
}
Comment

java join array

String[] data = { "First", "Second", "Third" };
StringBuilder sb = new StringBuilder();
for (String item : data) {
  sb.append(item).append(", ");
}
sb.setLength(sb.length() - 2);

// generates output:
// First, Second, Third
Comment

PREVIOUS NEXT
Code Example
Java :: how to compare two strings in java 
Java :: hash map 
Java :: spring login response data 
Java :: list of list in java 
Java :: top java interview coding questions 
Java :: How to remove an element from a Java List? 
Java :: how to return an object in java 
Java :: why string is immutable in java 
Java :: types of exception in java 
Java :: set array length java 
Java :: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. 
Java :: how to use another class in java inside of an action listenrer 
Java :: java crypto ke random 
Java :: java 8 iterating and manipulating list 
Java :: move gif in wave motion java 
Java :: how to declare a variable when using loops Java 
Java :: jkora 
Java :: get sha1 key from keystore 
Java :: REGEX ___ get length of array in java 
Java :: spring secutiry urls redirecting 
Java :: arraylist to java 
Java :: Picked up _JAVA_OPTIONS: -Xmx256M intillij 
Java :: inheritance setter and getter in java 
Java :: leap year java method 
Java :: mergesort parallelization using spark 
Java :: java catch stop signal 
Java :: Java @SuppressWarnings Annotation Example 
Java :: intList 
Java :: what is xml file in java 
Java :: java how to sort custom objects in descending orde 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =