Distribute the array into multiple arguments for the function

How to pass an array as three function arguments in Java? (Excuse me, I am very new to Java).

I have the following function that takes float r, float g, float b, float aas arguments.

renderer.prepare(r, g, b, 1);

And I want to pass the exit from this function to. (Or find out how to return three separate unpacked floats).

public static float[] rgbToFloat(int r, int g, int b) {
    return new float[] {(float) r / 255f, (float) g / 255f, (float) b / 255f};
}

How can i do this? In some other languages, it looks something like this:

renderer.prepare(...rgbToFloat(25, 60, 245), 1); 
+4
source share

Source: https://habr.com/ru/post/1680567/


All Articles