samedi 24 juin 2017

calling the static method in main class using reflection

this program recover the 2 group of the numbers from user that it compare then if the first one is bigger pointA receive one grade if not pointB receive one grade and it continues until last number.my problem is that i can't print the final result which the grade for pointA,pointB because of static method that i have in program.how can i print it there by using reflection or any other method?

public class Solution {
    static int[] solve(int a0, int a1, int a2, int b0, int b1, int b2){
      int pointA=0;
   int pointB=0;
        int FristArray[]={a0,a1,a2};
        int scoundArray[]={b0,b1,b2};
        for(int x=0;x<=FristArray.length;x++) 
        for(int y=0;x<=scoundArray.length;y++) 
            if (x>y){ 
                pointA+=1;
            }
        else if(x<y){  
            pointB+=1;
        }
       int points[]={pointA,pointB};
       return  points; 
    }

  public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a0 = in.nextInt();
        int a1 = in.nextInt();
        int a2 = in.nextInt();
        int b0 = in.nextInt();
        int b1 = in.nextInt();
        int b2 = in.nextInt();
        int[] result = solve(a0, a1, a2, b0, b1, b2);
        for (int i = 0; i < result.length; i++) {
              System.out.print(result[i]+"i want to print it here");
        }
        System.out.println("");
        

    }




Aucun commentaire:

Enregistrer un commentaire