public final class Main {
public static void main
(String[] args
) { var yellow
= Color.
findByName("YELLOW"); // Since 'yellow' can be null, the next statement may throw a
// NullPointerException.
var rgb = yellow.getRgb();
}
/**
Returns the Color instance that matches with the specified name.
@param name
...
@return
{@code null} if nothing matches with {@code name}.
Otherwise, the instance that matches.
*/
return null;
}
/**
Returns the 24-bit integer value representing RGB.
@return
...
*/
int getRgb();
}
}
cHVibGljIGZpbmFsIGNsYXNzIE1haW4gewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgdmFyIHllbGxvdyA9IENvbG9yLmZpbmRCeU5hbWUoIllFTExPVyIpOwoJCS8vIFNpbmNlICd5ZWxsb3cnIGNhbiBiZSBudWxsLCB0aGUgbmV4dCBzdGF0ZW1lbnQgbWF5IHRocm93IGEKCQkvLyBOdWxsUG9pbnRlckV4Y2VwdGlvbi4KICAgICAgICB2YXIgcmdiID0geWVsbG93LmdldFJnYigpOwogICAgfQoKICAgIHB1YmxpYyBpbnRlcmZhY2UgQ29sb3IgewoKICAgICAgICAvKioKCSAgICAgICAgUmV0dXJucyB0aGUgQ29sb3IgaW5zdGFuY2UgdGhhdCBtYXRjaGVzIHdpdGggdGhlIHNwZWNpZmllZCBuYW1lLgoKICAgICAgICAgICAgQHBhcmFtIG5hbWUKICAgICAgICAgICAgICAgIC4uLgogICAgICAgICAgICBAcmV0dXJuCgkgICAgICAgICAgICB7QGNvZGUgbnVsbH0gaWYgbm90aGluZyBtYXRjaGVzIHdpdGgge0Bjb2RlIG5hbWV9LgoJICAgICAgICAgICAgT3RoZXJ3aXNlLCB0aGUgaW5zdGFuY2UgdGhhdCBtYXRjaGVzLgogICAgICAgICovCiAgICAgICAgc3RhdGljIENvbG9yIGZpbmRCeU5hbWUoU3RyaW5nIG5hbWUpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQoKICAgICAgICAvKioKCSAgICAgICAgUmV0dXJucyB0aGUgMjQtYml0IGludGVnZXIgdmFsdWUgcmVwcmVzZW50aW5nIFJHQi4KCiAgICAgICAgICAgIEByZXR1cm4KICAgICAgICAgICAgICAgIC4uLgogICAgICAgICovCiAgICAgICAgaW50IGdldFJnYigpOwogICAgfQp9Cg==