我专门研究了addButtonClicked()方法和DBHandler本身.当我尝试向数据库添加内容时,我无法弄清楚为什么程序基本上陷入了无限循环.每次我运行它并尝试向数据库添加内容时,它只会冻结并反复提供此消息.
错误:
10-27 20:34:50.303 2849-2849/? I/art: Not late-enabling -Xcheck:jni (already on)
10-27 20:34:50.303 2849-2849/? I/art: Late-enabling JIT
10-27 20:34:50.312 2849-2849/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
10-27 20:34:50.408 2849-2849/com.example.test.assignment W/System: ClassLoader referenced unknown path: /data/app/com.example.test.assignment-2/lib/x86
10-27 20:34:50.966 2849-2860/com.example.test.assignment W/art: Suspending all threads took: 6.223ms
10-27 20:34:51.033 2849-2860/com.example.test.assignment I/art: Background partial concurrent mark sweep GC freed 423(15KB) AllocSpace objects, 418(7MB) LOS objects, 38% free, 6MB/10MB, paused 6.686ms total 54.772ms
10-27 20:34:51.577 2849-2860/com.example.test.assignment W/art: Suspending all threads took: 6.097ms
10-27 20:34:51.816 2849-2860/com.example.test.assignment …Run Code Online (Sandbox Code Playgroud) 我需要让用户输入一个数字作为范围的开头,然后输入另一个数字作为范围的结尾.起始编号必须为0或更大,结束编号不能大于1000.这两个编号必须可以被10整除.我找到了一种方法来满足这些条件,但如果不满足我的程序只是告诉用户他们的输入不正确.我是否可以对其进行编码,以便在用户输入后检查以确保满足条件,如果它们没有循环返回并再次输入.这是我到目前为止的代码.
Scanner keyboard = new Scanner(System.in);
int startr;
int endr;
System.out.println("Enter the Starting Number of the Range: ");
startr=keyboard.nextInt();
if(startr%10==0&&startr>=0){
System.out.println("Enter the Ending Number of the Range: ");
endr=keyboard.nextInt();
if(endr%10==0&&endr<=1000){
}else{
System.out.println("Numbers is not divisible by 10");
}
}else{
System.out.println("Numbers is not divisible by 10");
}
Run Code Online (Sandbox Code Playgroud)