is it possible to make 2 condition that you write string stament and int stagement and make an operation with them in java

huangapple 未分类评论49阅读模式
标题翻译

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(&quot;dd/MM/yyyy hh:mm:ss&quot;);											 
   if(issbookno_string.equals(&quot;&quot;))//if user don&#39;t fill out the issbook 
      name
   {  JOptionPane.showMessageDialog(issbook_window,&quot;no way&quot;);//print no 
        way to display
    }
   else 
                                                                    
   for(int i=0;i&lt;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,&quot;You have been succesfully issued a book&quot;);
												 
   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&#39;m not sure if this is because of the formatting or not, but ```//``` is used for single line comments, which means the &quot;name&quot; in the &quot;if user don&#39;t fill out the issbook name&quot; comment and &quot;way to display&quot; in the &quot;print no way to display&quot; aren&#39;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>



huangapple
  • 本文由 发表于 2020年5月30日 17:31:19
  • 转载请务必保留本文链接:https://java.coder-hub.com/62100519.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定