Skip to content

Yash-Jadaun/Variable_Arguments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Variable_Arguments

public class VariableArguments {

//static int sum(int a,int b){
  //  return a+b;

// }

// static int sum(int ...arr){ // int result=0; // for(int a: arr){ // result += a; // } // return result; // }

 static int sum(int x,int ...arr){
    int result=0;
    for(int a:arr){
        result +=a;
    }
      return result; 
}


public static void main(String[] args) {
  //  System.out.println("The sum of 4 and 5 is:" + sum(4,5,6));
      //System.out.println("The sum of 4,5,6,7,8" +" " + sum(4,5,6,7,8));
      System.out.println("Sum of nothing is" + " " + sum(5));
      
    }

}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published