/* package whatever; // don't place package name! */ import java.util.*;import java.lang.*;import java.io.*; /* Name of the class has to be "Main" only if the class is public. */class Ideone{ public static void main (String[] args) throws java.lang.Exception { String s = "TEXTO"; String textoinverso = ""; for(int x=0; x<s.length(); x++){ textoinverso += s.substring(s.length() - x - 1, 1); } System.out.println(textoinverso); }}
Standard input is empty
Standard output is empty
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 4, end 1, length 5 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3410) at java.base/java.lang.String.substring(String.java:1883) at Ideone.main(Main.java:16)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!