[Solved] how can i print this using String Methods


Thanks for all answers by you.
I got my answer for my question as i was trying..
sorry for uploading it late but got so many other ways to do it.
Here is my answer.

String res = "";
    public String altPairs(String str) {
        int i=0;
        while (i<str.length()) {
            res +=str.charAt(i);
            i=i+1;
            if(i<str.length()) {
                res+=str.charAt(i);
                i=i+3;
            }
        }
        return res;
    }

solved how can i print this using String Methods