How to join a array to string in Python

To join a array to string in Python you can use the following snippet.

Sample Python

def JoinArray(input, delimiter, appendToEnd):
	delimiter = ';'
	joinedString = delimiter.join(input)
	if appendToEnd:
		joinedString = joinedString + delimiter
		return joinedString
	else:
		return joinedString

list = ['This', 'is', 'a', 'Test','!']
print JoinArray(list, ';', False)

How to join a array to string in Java

To join a array to string in Java you can use the following snippet.

Sample Java

public static String JoinArraylist(List<String> input, String delimiter, Boolean appendToEnd){
	Iterator<String> iteratorString = input.iterator();
	StringBuilder stringBuilder = new StringBuilder();
	for (;;) {
		stringBuilder.append(iteratorString.next());
		if (!iteratorString.hasNext()){ 
			break;
		}
		stringBuilder.append(delimiter);
	}
	if(appendToEnd){
		stringBuilder.append(delimiter);
	}
	return stringBuilder.toString();
}