خرید بک لینک

Vote count: 0

So i have a program where i want to replace specific characters in the program with other letters. However, when i run this program, it seems to keep reverting the changed characters back. This is the code so far:

    for (int i = 0; i < sample.length(); ) {

        if (sample.charAt(i) == 'A') {

            sample = sample.replace(sample.charAt(i), 'B');
            i++;
            continue;

        }

        else if (sample.charAt(i) == 'B') {

            sample = sample.replace(sample.charAt(i), 'A');
            i++;
            continue;

        }

    }

Is there a way that i can iterate through each character in the string and then check if it is either an A, B, C, D, E, or F and change it to its complimentary letter, i.e. A to B, B to A, C to D, D to C, E to F, F to E.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 9 خرداد 1395 ساعت: 17:39

صفحه بندی