Revere the Statement Using java Program

Revere the Statement Using java Program 

public class RevStatement
 {

    public static void main(String []args)

    {

        String str=”i love india”;

        String []split= str.split(” “);

        String rev=””;

        for(int i=split.length-1;i>=0;i–)

        {

           rev+=(split[i]+” “);

        }

        System.out.println(rev);

    }

}

input: i love india

output: india love i

Leave a Reply