Java Varargs - Simple Addition

  • + 0 comments

    import java.io.; import java.lang.reflect.; import java.util.; import java.text.; import java.math.; import java.util.regex.;

    //Write your code here class Add{ public static void add(int ...n){ int result=0; for(Integer i:n){ result+=i; System.out.print(i); if(i==n[n.length-1]) { System.out.print("="); System.out.println(result); break;} System.out.print("+");

        }
    
    }
    

    }