public class ArrayMethod {
static int[] temps;
public static void create() {
temps = {28, 27, 28, 21, 21, 19, 18, 29, 31, 24};
}
}
I am required to use 'temps' in other methods but am getting a variety of errors.
public class ArrayMethod {
static int[] temps;
public static void create() {
temps = {28, 27, 28, 21, 21, 19, 18, 29, 31, 24};
}
}
I am required to use 'temps' in other methods but am getting a variety of errors.
initialize your array as below. The way you are using would give compile time error because array constants can only be used in initializers
temps = new int[]{28, 27, 28, 21, 21, 19, 18, 29, 31, 24};