Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java string join arraylist

// You can't just do String.join(", ", list) because
// the list has to be a String[]. This code works on
// everything.

list.stream().map(Object::toString).collect(Collectors.joining(", "));
Comment

java join list


List<String> list = Arrays.asList("foo", "bar", "baz");
String joined = String.join(" and ", list); // "foo and bar and baz"

Comment

java join list as string

List<String> list = Arrays.asList("a","b","c");
String result = String.join(",", list);

System.out.println(result);		//prints a,b,c
Comment

java join list

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 :: java double buffering jpanel 
Java :: android up navigation 
Java :: onbackpressed close the app in android 
Java :: spigot get commandmap 
Java :: android settextcolor programmatically 
Java :: for loop in multidimensional array java 
Java :: android plain text remove underline 
Java :: java get all items from arraylist 
Java :: change editext hint color android 
Java :: java send an image over a socket 
Java :: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade java.lang.OutOfMemoryError (no error message) 
Java :: junit 5 assert exception message 
Java :: joptionpane hello world 
Java :: javafx get window in controller 
Java :: How to efficiently count the number of smaller elements to the right of every array element, in Java? 
Java :: java get location of jar file 
Java :: android java format date time 
Java :: plus one java 
Java :: java parse string to list using gson 
Java :: how to delete a file in java 
Java :: int a=08 java 
Java :: How to efficiently find the middle node of a singly linked list without counting its nodes, in Java? 
Java :: difference between offer and add in linkedlist in java 
Java :: How to efficiently find the first duplicate value in an array of ints between 1 and the n, with n being the size of the array? 
Java :: calculate age from localdate java 
Java :: get block player is looking at bukkit 
Java :: writing to a text file java 
Java :: swing enter key 
Java :: load a file from classpath spring boot 
Java :: android studio fab icon color 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =