You are on page 1of 1

## Problem Statement

Write a Java program to print the characters at the odd position of a given string

## Input

Hey there!

## Output

e hr!

## Explanation

> All the characters (including whitespace) at the odd position of the string `Hey
there!` are printed.

## Solution:-
import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
String input = s.nextLine();
s.close();
char[] result = input.toCharArray();
for(int i=1;i<result.length;i=i+2){
System.out.print(result[i]);
}
}
}

You might also like