You are viewing a single comment's thread. Return to all comments →
Java Logic for Printing Even & Odd's characters of a String
Scanner sc = new Scanner(System.in); int T = sc.nextInt(); String S= null ; for(int i=0; i<T;i++) { S= sc.next(); char[] characters = S.toCharArray(); int j=0; for(j=0;j<characters.length;j++) { if(j%2==0){ System.out.print(characters[j]); } } System.out.print(" "); for(j=0;j<characters.length;j++) { if(j%2==1) { System.out.print(characters[j]); } } System.out.println(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 6: Let's Review
You are viewing a single comment's thread. Return to all comments →
Java Logic for Printing Even & Odd's characters of a String