How to reverse a string in Java without using reverse function?

To reverse a string in Java, call reversedString += string.charAt(i) in a backwards for loop.

In other words, add all characters of your string to another string in a reverse order, like so:

String string = "Hello World!";
String reversedString = "";

for (int i = string.length() - 1; i >= 0; i--) {
  reversedString += string.charAt(i);
}

System.out.println(reversedString); // !Dlrow olleH