. How do I swap odd elements in array of a String????? Eg: Input: I Love India Output will be: I voLe dnIia : 

            

                                                                          
  How do I swap odd elements in Array of a String????? Eg:  Input: I Love India  Output will be: I voLe dnIia                                              
 package com.String;

import java.util.Scanner;

public class swap_odd_element {

	public static void main(String[] args) {
		String s1= "I Love India";
		String[] arr= s1.split(" ");
		
		for(String s2:arr)
		{
			if(s2.length()>1)
			{
				char[] arr1= s2.toCharArray();
				int len=arr1.length;
				
				for(int i=0; i< len;i++)
				{
					 char temp=arr1[i];
					  arr1[i]=arr1[i+2];
					 arr1[i+2]= temp;
					 String swap = new String(arr1);
						
				}
			}
			else{
				System.out.println(s2);
			}
		}
		
	}

}
