日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java字符串与数组比较大小_java-如何将存储在数组中的字符串与简单字符串进行比较?...

發布時間:2023/12/1 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java字符串与数组比较大小_java-如何将存储在数组中的字符串与简单字符串进行比较?... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我想比較數組中字符串形式的學生人數與人數n

這是字符串。

remarque:

班級形成:

私有字符串代碼;

私有字符串名稱;

private int nbsi = 0;

私人學生[]標簽=新學生[200];

班級學生:

私有字符串號;

``

私有字符串名稱;

私有字符串name2;

public Module []選項卡= new Module [4];

塊引用類的形成

package tp2_bis;

public class Formation

{

//question 2

private String code;

private String name;

private int nbsi=0;

private Student [] tab = new Student[200];

//question 3

public Formation(String code,String name)

{

this.setCode(code);

this.setName(name);

}

public Formation()

{

}

//question 4

public String getCode()

{

return code;

}

public void setCode(String code)

{

this.code = code;

}

public String getName()

{

return name;

}

public void setName(String name)

{

this.name = name;

}

public int getNbsi()

{

return nbsi;

}

public void setNbsi(int nbsi)

{

this.nbsi = nbsi;

}

//question 6_b

public boolean searchName(String n1)

{

int i=0;

boolean b=false;

while(!b && i

{

if(tab[i].getName().equals(n1)) //there is the problem i cant compare between them??

b=true;

else

i++;

}

return b;

}

}

班級班級學生=>班級組建

package tp2_bis;

public class Student

{

//question 2

private String number;

private String name;

private String name2;

public Module[] tab = new Module[4];

//question 3

public Student(String name,String name2)

{

this.setName(name);

this.setName2(name2);

}

public Student()

{

}

//question 4

public String getNumber()

{

return number;

}

public void setNumber(String number)

{

this.number = number;

}

public String getName()

{

return name;

}

public void setName(String name)

{

this.name = name;

}

public String getName2()

{

return name2;

}

public void setName2(String Name2)

{

this.name2 = name2;

}

public Module[] getTab()

{

return tab;

}

public void setTab(Module[] tab)

{

this.tab = tab;

}

//question 5_a

public void addMark(Module m)

{

int i=0;

boolean b=false;

while(i<4 && !b)

{

if(this.tab[i]==null)

{

this.tab[i]=m;

b=true;

}

else

i++;

}

}

public void addMark(String name,double mark,int cof)

{

Module m=new Module(name,mark,cof);

int i=0;

boolean b=false;

while(i<4 && !b)

{

if(this.tab[i]==null)

{

this.tab[i]=m;

b=true;

}

else

i++;

}

}

public void write()

{

Module[] tab1= this.tab;

System.out.println("numero d'inscription:"+this.getNumber()+

"\nNom et Prenom de l'etudiant: "+this.getName()+" "+this.getName2()+

"\nNotes:");

}

Blockquote的主要功能

package tp2_bis;

public class TestFormation

{

public static void main(String[] args)

{

Formation f=new Formation("CPI_2016","class of computer science");

Etudiant e1=new Etudiant("ali","djamel");

Etudiant e2=new Etudiant("karim","rachid");

f.inscription(e1);

f.inscription(e2);

Module m1=new Module("algo",19,5);

e1.addMark(m1);

e1.addMark("analyse",17,5);

m1=new Module("algebre",20,3);

e1.addMark(m1);

m1=new Module("archi",15,4);

e1.addMark(m1);

e1.write();

e2.addMark(new Module("algo",17,5));

e2.addMark(new Module("analyse",18,5));

e2.addMark("algebre",20,3);

e2.addMark("archi",15,4);

e2.write();

System.out.println(f.searchName("karim"));

}

}

總結

以上是生活随笔為你收集整理的java字符串与数组比较大小_java-如何将存储在数组中的字符串与简单字符串进行比较?...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。