import java.util.Arrays;
public class CharacterRangeArray {
public static char[] CreateCharacterRangeArray(char startChar, char endChar) {
if (endChar < startChar) {
throw new IllegalArgumentException("End character must be greater than or equal to start character.");
}
char[] charArray = new char[endChar - startChar + 1];
for (int i = 0; i <= endChar - startChar; i++) {
charArray[i] = (char) (startChar + i);
}
return charArray;
}
public static void main(String[] args) {
// Create an array of lowercase characters
char[] charArray = CreateCharacterRangeArray('a', 'm');
System.out.println(Arrays.toString(charArray));
// Create an array of uppercase characters
char[] upperCaseArray = CreateCharacterRangeArray('A', 'M');
System.out.println(Arrays.toString(upperCaseArray));
}
}
/*
run:
[a, b, c, d, e, f, g, h, i, j, k, l, m]
[A, B, C, D, E, F, G, H, I, J, K, L, M]
*/