For this Question: There is a string s is given as input. reverse the string and make the even character as null and print the resultant string.
Note: string s is not null.There is a string s is given as input.
1 <= s. length <= 10<sup>5</sup>
s is having only lowercase letters.reverse the string and make the even character as null and print the resultant string.Sample Input:
egrtgrg

Sample Output:
ggre

Explanation:
Reversed string:grgtrge
final string after removing 2, 4, 6 characters is ggre., I have written this Solution Code: import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        String rev="";
        for(int i=s.length()-1;i>=0;i--){
            rev+=s.charAt(i);
        }
        String ans="";
        for(int i=0;i<s.length();i++){
            if(i%2==0){
               ans+=rev.charAt(i);
            }
        }
        System.out.println(ans);
        return;
    }
}

, In this Programming Language: Java, Now tell me if this Code is compilable or not?