class A
{
void add(int ... a)
{
int sum=0;
for(int x:a)
{
sum=sum+x;
}
System.out.println("sum of numbers will be "+sum);
}
}
class B
{
public static void main(String[] args)
{
A r= new A();
r.add();
r.add(10,20);
r.add(20,30);
r.add(20,20);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter