We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
//Write your code hereclassAdd{publicvoidadd(int...a){intsum=0;for(inti=0;i<a.length;i++){if(i<a.length-1){System.out.print(a[i]+"+");}sum=sum+a[i];}System.out.print(a[a.length-1]+"="+sum);System.out.println();}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Varargs - Simple Addition
You are viewing a single comment's thread. Return to all comments →