code to reverse a string
//make a scanner object
Scanner input = new Scanner(System.in);
//take in an input string and store it inside a <String> variable
System.out.println("Enter the string: ");
String string = input.nextLine();
//convert string to character arraylist by first creating
//an array list for the characters in correct order
//and an array list for what we will use
//to store the characters in reverse order later in the code
ArrayList<Character> chars = new ArrayList<Character>();
ArrayList<Character> reversed = new ArrayList<Character>();
//put all the characters from string into chars arrayList
for (char c : string.toCharArray()) {
chars.add(c);
}
//get the size of the arraylist
Integer length = chars.size() - 1;
Integer x = 0;
//loop all the elements in the array chars into reversed arraylist in reverse order
while(x < chars.size()) {
reversed.add(chars.get(length));
length -= 1;
x += 1;
}