vendredi 29 mai 2015

I am getting an else without if error and I don't understand why - JAVA

public class ProblemFour

{

    public static void main(String[] args)
    {

            boolean externalCheck = true;
            boolean internalCheck = true;
            String Str = new String();
            int prod = 0;
            int mod = 0;

                    while (externalCheck == true){

                            for (int a = 999; a>99; a--){
                                    for(int b = 999; b>99; b--){
                                            prod = a*b;
                                            Str = Integer.toString(c);

                                                    if (internalCheck == true && mod < Str.length()/2){

                                                            if (c%2 ==0){
                                                                    for(int i =0; i<Str.length(); i++){
                                                                            if(Str.substring(i) != Str.substring(Str.length()-1)){
                                                                                    internalCheck = false;
                                                                            }
                                                                            else{
                                                                                    mod++;
                                                                            }
                                                                    }
                                                            else{
                                                                    String S= Str.substring(0,(Str.length()-1)/2) + Str.substring(Str.length()/2, Str.length());

                                                                            for(int i =0; i<S.length(); i++){
                                                                                    if(S.substring(i) != Str.substring(S.length()-1)){
                                                                                             internalCheck = false;
                                                                                    }
                                                                                    else{
                                                                                            mod++;
                                                                                    }
                                                                            }
                                                            }

                                                    }
                                                    else {
                                                            return Str;
                                                            System.out.println(Str);
                                                            externalCheck = false;
                                                    }

I am getting an error that says I have an else without and if and I don't understand where this is coming from. Specifically on line 31. What more detail do i need. is this not enough detail

Aucun commentaire:

Enregistrer un commentaire