【发布时间】:2015-01-20 01:11:53
【问题描述】:
构造函数中的 if 应该检查输入是否合法......编译器似乎不同意我的观点,它给了我“';'预期”在 if 语句之后,我不明白为什么请帮忙。
public class RGBColor
{
private int _red,_green,_blue;
private final int _MAX_INTENSITY = 255,_MIN_INTENSITY = 0;
/**
* Constructor for objects of class RGBColor
*/
public RGBColor()
{
_red = 0;
_green = 0;
_blue = 0;
}
public RGBColor(int red, int green,int blue)
{
If ((_red < _MIN_INTENSITY) || (_red > _MAX_INTENSITY) || (_green < _MIN_INTENSITY) || (_green > _MAX_INTENSITY) || (_blue < _MIN_INTENSITY) || (_blue > _MAX_INTENSITY)) \\<<I get the error here
{
_red=0;
_green=0;
_blue=0;
}
else
{
_red = red;
_green = green;
_blue = blue;
}
}
}
【问题讨论】:
-
If与if。\\与//. -
我的猜测是,
if应该是小写的。 -
很抱歉这篇愚蠢的帖子...感谢您的快速回复
标签: java if-statement bluej