Reverse a word from the given string in Java
public class Test
{
public static void main(String[] args)
{
String str = "welcome to the java world";
String split[] = str.split(" ");
// I want to reverse java from the given String
String s= split[3];
String rev="";
for(int i=s.length()-1; i>=0; i--)
{
rev = rev+s.charAt(i);
}
System.out.println(rev);
}
}
---------------------------------------------------------------------------------------------------------------------------------
avaj
Comments
Post a Comment