Write a java program to print alternate letters in a string.
Answers
Answered by
1
Answer:
to print alternate letters in a string:
Explanation:
public class main{
public static void main(String[] args) {
String s = "BrainlyCells";
//i+=2 skips the odd indexed characters, you can start from i=1 to skip the even characters
for(int i=0;i<s.length();i+=2) {
System.out.println(s.charAt(i));
}
}
Similar questions