Ciao a tutti, ho fatto questo semplice programmino per rovesciare una stringa, ma quando vado a mandare in out la stringa prodotta, mi scrive cose strane:
Dove sbaglio?codice:class StringUtils { public static String reverse( String a ) { char[] array = new char[a.length()]; int from = 0, to = a.length() - 1; while( from <= to ) { char tmp = a.charAt( from ); array[from] = a.charAt(to); array[to] = tmp; from++; to--; } String newString = new String(); newString = array.toString(); return newString; } }
Grazie!!