Ejemplo1

mail@pastecode.io avatar
unknown
java
2 years ago
900 B
2
Indexable
Never
public static String ejemplo1(String s1){

        String s2="";
        String s3="";
        //['V','A','R','L','O','P','E']
        s2 = s1.charAt(5) + s1.substring(1,3);

        //S2 = "P" + "ar"
        //S2= "par"

        for(int i =3 ; i<= 4; i++){
            //s3 = "l"  + "";
            //s3 = "o" + "l"
            s3 = s1.charAt(i) + s3;
            System.out.println("iteracion:" + i);

            //s3 = "ol"
        }
        //
        if(s3.contains("lo")){
            s2 = s3 + s2.substring(1,3) + s1.charAt(3);
        }else if(s3.indexOf('p') == -1){
            //s2 = "p" + "ol" + "ar"
            //s2 = "polar"
            s2= s2.substring(0,1) + s3 + s2.substring(1);
        }else{
            s2 = s3.charAt(0) + s2 + "i";
        }


        //s3 = "el";
        s3.replace('o','e');
        // s2 = "polar"
        return s2;
    }