Вам не нужно использовать цикл for с оператором setInterval
. Попробуйте это:
var list = Array(...);
var x = 0;
setInterval(function() {
if (x < list.length;) {
list[x] += 10;
console.log(x+"=>"+list[x]);
}
else return;
x++;
}, 5000);
Вы должны получить исключение IllegalArgumentException
, если имя не является именем перечисления (которое не будет для пустой строки). Это генерируется в документации API для всех методов enum valueOf
. Вы должны получить NullPointerException
для null
. Вероятно, не рекомендуется давать фиктивное значение переменной String
(и не допускать, чтобы последний случай
/ по умолчанию
не выполнялся).
Я только что попробовал ваш код. Это вызывает исключение IllegalArgumentException
. Как и указано в документации.
метод: valueOf
Returns the enum constant of the specified enum type with the specified name. The name must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Parameters:
enumType - the Class object of the enum type from which to return a constant
name - the name of the constant to return
Returns:
the enum constant of the specified enum type with the specified name
Throws:
IllegalArgumentException - if the specified enum type has no constant with the specified name, or **the specified class object does not represent an enum type**
NullPointerException - if **enumType or name is null**
, чтобы отмечать эти исключения,