Java tutorial
//package com.java2s; public class Main { public static String getOddOrEvenString(String src, int type) { if (src == null || src.length() <= 0) { return ""; } StringBuffer sb = new StringBuffer(); int sbLength = src.length(); for (int i = 0; i < sbLength; i++) { if (i % 2 == type) { sb.append(src.charAt(i)); } } return sb.toString(); } }