If statement 为SQL安全设置空值时出现打印错误
If statement 为SQL安全设置空值时出现打印错误,if-statement,jtextfield,If Statement,Jtextfield,JTextfield为空时,如何打印“Error” save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String sn =jX1.getText(); if (sn==null){ System.out.println("Error"); System.out.prin
JTextfield
为空时,如何打印“Error”
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
String sn =jX1.getText();
if (sn==null){
System.out.println("Error");
System.out.println("T");
}
谢谢尝试使用故障保护方法。同时在注释上扩展,您应该以更好的格式记录数据。Java拥有大量不同的方法来记录某些数据 至于错误处理,请尝试最终捕获。这不是经过测试的代码。如果您遇到任何问题、关于try-catch的文档和其他语句或
System.out
将写入终端。如果你想给终端写信,我想你会这么做,但你没有明确说明你是否想这么做。
public static void main(String[] args) {
while (String sn == null)
try {
String sn = JX1.getText();
} catch (Exception ex) {
System.out.println("Exception thrown!");
} finally {
if (sn != null) {
System.out.println("Closing PrintWriter");
sn.close();
} else {
System.out.println("PrintWriter not open");
}
}