Answer the question
In order to leave comments, you need to log in
How to solve the problem and why does the compiler swear at the parameters?
There is a task:
You need to write a method that has three integer parameters and returns the maximum of them.
but the compiler swears at the parameters, why? What I've done:
package homeWorks;
import java.util.Arrays;
import java.util.Scanner;
class HW1 {
public static void main(String[] args) {
// методы в методе main должны иметь модификатор static
public static int getValue(int a, int c, int b){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the first value: ");
a = sc.nextInt();
System.out.println("Enter the second value: ");
b = sc.nextInt();
System.out.println("Enter the third value: ");
c = sc.nextInt();
int[] array = new int[3];
array[0] = a;
array[1] = a;
array[2] = c;
Arrays.sort(array);
System.out.println("max value is " + array[2]);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question