Static method not called

Posted by Smile on Stack Overflow See other posts from Stack Overflow or by Smile
Published on 2010-12-31T19:36:33Z Indexed on 2011/01/03 9:53 UTC
Read the original article Hit count: 244

Filed under:
|
|

I'm trying to call a static method (printABC()) in this class but it's not working.

If I uncomment both of the lines marked T_T (1 and 2), it works! Why does it fail with only one of the lines?

import java.util.Scanner;

class pro0009 {
   static Scanner in = new Scanner(System.in);
   static int A,B,C;

   static void printABC(){
      String ABC = in.nextLine(); 

      ABC=ABC.replace("A"," "+A+" ");
      ABC=ABC.replace("B"," "+B+" ");
      ABC=ABC.replace("C"," "+C+" ");

      //System.out.print(ABC.substring(1));
      System.out.print(ABC);
   }

   public static void main(String[] args){
      int x = in.nextInt(); //1
      int y = in.nextInt(); //2
      int z = in.nextInt(); //3


      if(x<y){//1<2
         if(x<z){ //1<3
            if(y<z){//x<y<z 2<3
               //1<2<3
               A=x;
               B=y;
               C=z;
               printABC();//T_T 1
               System.out.println("Here");
               //pro0009.printABC();//T_T 2
               //System.out.println("Here2");
            }else{ //x<z<y
               A=x;
               B=z;
               C=y;

            }
         }else{//z<x<y
            A=z;
            B=x;
            C=y;

         }
      }else{//y<x
         if(y<z){
            if(x<z){//y<x<z
               A=y;
               B=x;
               C=z;

            }else{//y<z<x
               A=y;
               B=z;
               C=x;

            }
         }else{//z<y<x
            A=z;
            B=y;
            C=x;

         }
      }
   }

}

© Stack Overflow or respective owner

Related posts about java

Related posts about homework