小さな色合いのメソッドの作成に取り組んできましたが、同じIndexOutOfBoundsException
エラーが発生し続けます。私はこれに多くを見逃しているとは思わないでしょうか?
import java.util.ArrayList;
public class Shades {
public static String shades(String hex, int offset) {
hex = hex.replace("#", "");
String[] rgb_hex = hex.split(".{2}");
ArrayList<Integer> rgb_int = new ArrayList<>();
for (String i : rgb_hex) {
int intg = Math.min(255, Math.max(
0, Integer.parseInt(i, 16) + offset));
rgb_int.add(intg);
}
return String.format("%02x%02x%02x", rgb_int.get(0),
rgb_int.get(1), rgb_int.get(2));
}
public static void main(String[] args) {
System.out.println(shades("#000000", 20));
}
}