Reversing a string
Logically, reversing is swapping the values from index 1 with index n, index 2 with index n-1, and so on.
So, if the string is "IncludeHelp", then the reverse will be "pleHedulcnI".
Example:
Input:
String: "IncludeHelp"
Output:
Reversed string: "pleHedulcnI"
Program to reverse a string in Scala
Output
Another method will be to convert the string into a list and then reversing the list and the converting in back to the string.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer