Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java string stringbuilder remove trailing comma

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 :: multiple return values in function java 
Java :: annotation spring notnull 
Java :: @entity annotation in spring boot 
Java :: java enum from int 
Java :: Get the number of weeks between two dates 
Java :: java resto 
Java :: how to set default color in android studio 
Java :: java printstacktrace 
Java :: xml button color not changing 
Java :: java tamanho de um vetor 
Java :: @runwith junit 5 
Java :: java get class by string name 
Java :: sololearn bowling game 
Java :: /bin/sh 1 java not found docker 
Java :: java 8 list to map with occurrences 
Java :: LocalRegistry java rebind() java8 
Sql :: how to get the size of the database in postgresql 
Sql :: postgresql reset sequence 
Sql :: oracle get table schema 
Sql :: turn on foreign keys check mysql 
Sql :: view column data type sql 
Sql :: stpop start psql server 
Sql :: drop all table postgresql 
Sql :: oracle to_timestamp 
Sql :: update part of a string in mysql 
Sql :: run postgres with docker 
Sql :: VERIFY INDEXES IN SQL ORACLE 
Sql :: alter table engine mysql 
Sql :: oracle first day of last year 
Sql :: change varchar length mysql 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =