You can use the String.charAt() method on the string. We can encapsulate that method inside of the String.valueOf function which will convert it to a string. Then you can store each element inside of the temp string. Although, with the looks of this program, i'm not sure why you don't just make temp a char? As an argument it will take the index of the character that you want to extract from the string. We can pass "i" as the argument each time through the for loop. You also need to say "i < message.length" in your conditional statement within the for loop because String indexes start at 0 in Java just like array indexes. Here is an example:
public static void main(String[] args) {
String message = "message";
String temp = "";
for (int i = 0; i < message.length(); i++) {
temp = String.valueOf(message.charAt(i));
System.out.print(temp);
}
}
As you can see, we have to set i to < message.length instead of <= or we will get an index out of range error. Here is your output from executing the code:
message