标题翻译
is it possible to make 2 condition that you write string stament and int stagement and make an operation with them in java
问题
以下是翻译好的部分:
public class lib {
public lib() {
gui();
}
int kitapno[] = new int[10];
int kitapnoindex;
int quantity[] = new int[10];
int quantityindex;
int kitapadetleri;
public void gui() {
// ...
public void actionPerformed(ActionEvent e) {
String issbookno_string = issbookno_text.getText();
int issbookno_int = Integer.parseInt(issbookno_string);
Date pt_issbook = new Date();
DateFormat ptformat_issbook = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
if (issbookno_string.equals("")) {
JOptionPane.showMessageDialog(issbook_window, "no way");
} else {
for (int i = 0; i < kitapno.length; i++) {
if (issbookno_int == kitapno[i]) {
row_issue[0] = kitapno[i];
row_issue[1] = issstudentid_text.getText();
row_issue[2] = issstudentname_text.getText();
row_issue[3] = issstudentcontact_text.getText();
row_issue[4] = ptformat_issbook.format(pt_issbook);
JOptionPane.showMessageDialog(issbook_window, "You have been succesfully issued a book");
model_issue.addRow(row_issue);
}
}
}
});
}
}
注意:由于您要求只返回翻译好的代码部分,我已删除了部分您提供的注释和文本。如果您需要完整的代码和内容,请随时询问。
英文翻译
I want the program that if user doesn't write any value in bookno jtexfield which is named issbook_text in my program,it would give a error message like 'no way'
I wrote those codes but normally I expected it to work like I wish but it doesn't .what is my mistake ,I could not find it for days.
public class lib {
public lib()
{
gui();
}
int kitapno[]=new int[10];
int kitapnoindex;
int quantity[]=new int[10];
int quantityindex;
int kitapadetleri;
public void gui()
{
public void actionPerformed(ActionEvent e)
{String issbookno_string=issbookno_text.getText();
int issbookno_int=Integer.parseInt(issbookno_string);
Date pt_issbook=new Date();
DateFormat ptformat_issbook=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
if(issbookno_string.equals(""))//if user don't fill out the issbook
name
{ JOptionPane.showMessageDialog(issbook_window,"no way");//print no
way to display
}
else
for(int i=0;i<kitapno.length;i++)
{ if(issbookno_int==kitapno[i])
{ row_issue[0]=kitapno[i];
row_issue[1]=issstudentid_text.getText();
row_issue[2]=issstudentname_text.getText();
row_issue[3]=issstudentcontact_text.getText();
row_issue[4]=ptformat_issbook.format(pt_issbook);
JOptionPane.showMessageDialog(issbook_window,"You have been succesfully issued a book");
model_issue.addRow(row_issue);
}
}
} });[enter image description here][1]
答案1
得分: 0
if (issbookno_string.equals(""))//如果用户未填写issbook名称
{
JOptionPane.showMessageDialog(issbook_window, "无方式显示");//显示无方式可显示
}
我不确定这是否是因为格式问题,但是 //
被用作单行注释,这意味着在 if user don't fill out the issbook name
注释中的 name
和在 print no way to display
注释中的 way to display
实际上并没有被注释掉,因为它们与双斜杠位于不同行。为了添加多行注释,你可以使用 /*
将注释括起来。
<details>
<summary>英文翻译</summary>
if(issbookno_string.equals(""))//if user don't fill out the issbook
name
{ JOptionPane.showMessageDialog(issbook_window,"no way");//print no
way to display
}
I'm not sure if this is because of the formatting or not, but ```//``` is used for single line comments, which means the "name" in the "if user don't fill out the issbook name" comment and "way to display" in the "print no way to display" aren't actually being commented, as they are on separate lines from the double slash. In order to add multi line comments, you could enclose the comments with ```/*``` instead.
</details>
专注分享java语言的经验与见解,让所有开发者获益!
评论