问题描述
我正在尝试通过文件中的电话号码验证进行额外的功劳分配。大部分结构都是由老师提供的,我必须填写或添加某些部分。我不断收到“其他情况,如果没有”错误,从我看到的内容来看,我没有包含任何“;”。在if / else / else if语句之后,因此我不知道为什么会收到此错误。
import java.util.*;
import javax.lang.model.util.ElementScanner6;
import java.io.*;
import static java.lang.System.*;
public class Main
{
public static void main(String[] args) throws IOException
{
Scanner input = new Scanner(new File("ValidPhoneNumber.dat"));
int lines = input.readLine();
input.nextLine();
String phoneNumber = ' ';
for (int i=0; i<lines; i++)
{
phoneNumber = input.nextLine;
if (phoneNumber.length() == 14)
{
out.println("Valid");}
else{
out.println("Invalid");
}
else if (phoneNumber.length() == 12) //error here
{
out.println("Valid");}
else
{out.println("Invalid");
}
else //error here
{
out.print("Invalid");
}
}
input.close();
}
}
错误出现在第63行和第72行
else if (phoneNumber.length() == 12)
和
else
{
out.print("Invalid");
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)