how to reverse the string code example
Example 1: how to reverse a string in python
string = "racecar"
print(string[::-1])
Example 2: how to reverse a string in java
public class ReverseString {
public static void main(String[] args) {
String s1 = "neelendra";
for(int i=s1.length()-1;i>=0;i--)
{
System.out.print(s1.charAt(i));
}
}
}
Example 3: code to reverse a string
int main()
{
char s[100];
printf("Enter a string to reverse\n");
gets(s);
strrev(s);
printf("Reverse of the string: %s\n", s);
return 0;
}
Example 4: reverse a string
let t = s.chars().rev().collect::<String>();