我有一段代码:
String textFieldContents = myJTextField.getText(); // javax.swing.JTextField
// If two consecutive pipes exist in the text, or if the text ends with a pipe, print a statement.
if(textFieldContents.matches("||") || textFieldContents.endsWith("|"))
System.out.println("We have a winner!");
当myJTextField
文本字段(Swing 组件)为空且其中没有文本时,将We have a winner!
打印文本。为什么?