不久前我问过这个阵列,我看不出是什么问题.太累了.我做错了什么?基本上,我正在使用字符串数组并尝试检查它是否包含数字或x(ISBN号验证).我想从给定输入(bookNum)中获取数字,检查输入,并将任何有效输入提供给新数组(书).在线
'bookNum.charAt[j]==book[i]'
Run Code Online (Sandbox Code Playgroud)
我得到'不是声明错误'.是什么赋予了?
String[] book = new String [ISBN_NUM];
bookNum.replaceAll("-","");
if (bookNum.length()!=ISBN_NUM)
throw new ISBNException ("ISBN "+ bookNum + " must be 10 characters");
for (int i=0;i<bookNum.length();i++)
{
if (Character.isDigit(bookNum.charAt(i)))
bookNum.CharAt[j]==book[i];
j++;
if (book[9].isNotDigit()||
book[9]!="x" ||
book[9]!="X")
throw new ISBNException ("ISBN " + bookNum + " must contain all digits" +
"or 'X' in the last position");
Run Code Online (Sandbox Code Playgroud) java ×1