
function arguments in java

Command line argument in Java
import java.util.*;
public class SumAndAverage{
public static void main (String [] arg) {
Scanner scan = new Scanner (System.in);
int [] numbers = new int [10];
int sum=0;
System.out.print("Enter 10 numbers");
for (int i=0; i<numbers.length; i++) {
numbers[i]=scan.nextInt ();
sum+=numbers[i];
}
System.out.println("Sum of Numbers: "+sum);
System.out.println("Average of Numbers: "+sum/10);
}
}

public class Swapping{
static void swap(int i,int j){
int temp=i;
i=j;
j=temp;
System.out.println("After swapping i = " + i + " j = " + j);
}
public static void main(String[] args){
int i=1;
int j=2;
System.out.prinln("Before swapping i="+i+" j="+j);
swap(i,j);
}
}
In the above code, the values of i and j are function arguments.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.