【发布时间】:2016-06-21 04:52:32
【问题描述】:
您好,我的作业问题:
为name字段传递的参数不能为null,
并且不能是空字符串或仅组成的字符串
的空白。如果作为参数传递的参数是
3 null 或空/空白字符串,将字段设置为
DEFAULT_POOL_NAME 否则,格式化值
正确(删除空格,首字母大写,
将其余部分设置为小写),然后再将其存储在实例中
变量。
这是我的代码:
public Pool(String newName, double newVolumeLitres, double newTemperatureCelsius, double newPH, double newNutrientCoefficient) {
if (newName != null && newName.trim().length() > 0) {
name = formatNameTitleCase(newName.trim());
} else {
name = DEFAULT_POOL_NAME;
}
}
我收到一条错误消息,指出
cannot find symbol - method formatNameTitleCase(java.lang.string)
【问题讨论】:
-
抱歉粘贴不好。
-
了解如何格式化您的代码
-
公共池 (String newName, double newVolumeLitres, double newTemperatureCelsius, double newPH, double newNutrientCoefficient) { if (newName != null && newName.trim().length() > 0) { name = formatNameTitleCase (newName.trim()); } 其他 { 名称 = DEFAULT_POOL_NAME; }
-
所以我收集到的是 formatNameTitleCase 不存在。
-
我猜是你,但我不认为我只是想把首字母大写,其余小写
标签: java