class Example
{
int[] values = {5, 1, 2};
for (int value : values) {
if (value < smallest) {
smallest = value;
} else if (value > largest) {
largest = value;
}
}
System.
out.
println(smallest
+ ", " + largest
); // 1, 2 -- WRONG }
}
Y2xhc3MgRXhhbXBsZQp7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB0aHJvd3MgRXhjZXB0aW9uIHsKICAgICAgICBpbnRbXSB2YWx1ZXMgPSB7NSwgMSwgMn07CiAgICAgICAgaW50IHNtYWxsZXN0ID0gSW50ZWdlci5NQVhfVkFMVUU7CiAgICAgICAgaW50IGxhcmdlc3QgID0gSW50ZWdlci5NSU5fVkFMVUU7CiAgICAgICAgZm9yIChpbnQgdmFsdWUgOiB2YWx1ZXMpIHsKICAgICAgICAgICAgaWYgKHZhbHVlIDwgc21hbGxlc3QpIHsKICAgICAgICAgICAgICAgIHNtYWxsZXN0ID0gdmFsdWU7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodmFsdWUgPiBsYXJnZXN0KSB7CiAgICAgICAgICAgICAgICBsYXJnZXN0ID0gdmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKHNtYWxsZXN0ICsgIiwgIiArIGxhcmdlc3QpOyAvLyAxLCAyIC0tIFdST05HCiAgICB9Cn0K