1 | initial version |
There are several ways to automate Int and Character Sequence using Java. Here are a few examples:
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
This will print the numbers 0 to 9 in the console.
for (char c = 'a'; c <= 'z'; c++) {
System.out.println(c);
}
This will print the letters a to z in the console.
String nums = "1 2 3 4 5";
String[] numArray = nums.split(" ");
int[] intArray = new int[numArray.length];
for (int i = 0; i < numArray.length; i++) {
intArray[i] = Integer.parseInt(numArray[i]);
}
This will create an int array containing the numbers 1 to 5.
String str = "Hello world";
char[] charArray = str.toCharArray();
for (char c : charArray) {
System.out.println(c);
}
This will print each character of the string "Hello world" in the console.