Pregunta de entrevista de Apple

How do you reverse a string?

Respuestas de entrevistas

Anónimo

23 mar 2020

Using inbuilt function reverse() or by using for loop. E.g: String str = "Reverse a string program"; String temp =""; System.out.println ("String before reversing" +str); for (int i =str.length()-1; i>=0;i--) { temp = temp+str.charAt(i) } System.out.println("String after reverse" +temp);

1

Anónimo

1 abr 2016

Point at the start of the string and the end and work till you hit the middle.

1