- String.join("구분자","대상 list or array")
- 문자열을 연결하는 java 메서드
String.join 사용예시
import java.util.ArrayList;
import java.util.List;
public class StringJoinExample {
public static void main(String[] args) {
String[] fruits = {"Apple", "Banana", "Orange"};
String joinedFruits = String.join(", ", fruits);
System.out.println("Joined fruits: " + joinedFruits);
List<String> colors = new ArrayList<>();
colors.add("Red");
colors.add("Green");
colors.add("Blue");
String joinedColors = String.join(" - ", colors);
System.out.println("Joined colors: " + joinedColors);
}
}