This is not the idea of functions.
functions are actions, they accept parameters, calculate stuff and return a value.
for example this is a function that returns the average of 3 numbers:
public static int avarage(int a, int b, int c) {
int sum = a + b + c;
int result = sum / 3;
return result;
}
You probably found information about javascript’s dictionary, which have different syntax from java’s function, although both of them have {
and }
You can use the following approach:
public static class Main {
public static int[] arr1 = {1,2,3};
public static int[] arr2 = {10,20,30};
public static void main(String[] args) {
System.out.println(arr2[1]);
}
}
in this code, arr1
and arr2
are static variables.
You can also use a Map or a Class instead
EDIT:
another approach will be to use 2 dimensional array:
public static class Main {
public static int[][] frame1 = {
{1,2,3},
{10,20,30}
};
public static int[][] frame2 = {
{4,5,6},
{40,50,60}
};
public static void main(String[] args) {
System.out.println(frame1[1][1]);
}
}
solved Access a certain array inside a method