| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 366 人关注过本帖
标题:[求助]我这个程序出了什么问题??
只看楼主 加入收藏
luyihuaa5201
Rank: 2
等 级:论坛游民
帖 子:254
专家分:10
注 册:2007-3-25
结帖率:66.67%
收藏
 问题点数:0 回复次数:1 
[求助]我这个程序出了什么问题??


import java.io.*;

public class FoundStaff {

private String staId;

private String staName;

private String staSex;

private String staUserName;

private String staPassWord;

public void Staffer(String Id, String Name, String Sex, String UserName,
String PassWord) {

staId = Id;
staName = Name;
staSex = Sex;
staUserName = UserName;
staPassWord = PassWord;

}

public String getStaId() {
return staId;
}

public void setStaId(String staId) {
this.staId = staId;
}

public String getStaname() {
return staName;
}

public void setStaname(String staname) {
this.staName = staname;
}

public String getStaPassWord() {
return staPassWord;
}

public void setStaPassWord(String staPassWord) {
this.staPassWord = staPassWord;
}

public String getStaSex() {
return staSex;
}

public void setStaSex(String staSex) {
this.staSex = staSex;
}

public String getStaUserName() {
return staUserName;
}

public void setStaUserName(String staUserName) {
this.staUserName = staUserName;
}

/**
* @param args
*/
public static void main(String[] args)
throws IOException{
// TODO 自动生成方法存根

FoundStaff[] staff = new FoundStaff[3];

staff[0]=new FoundStaff();

staff[0].Staffer("1000","luyihua","男","zhongguo" ,"123456");

staff[1] =new FoundStaff();
staff[1].Staffer("1001","luyihua","男","zhongguo" ,"123456");

staff[2]=new FoundStaff();
staff[2].Staffer("1003","luyihua","男","zhongguo" ,"123456");


System.out.println("请输入要查询的学号:");
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
String num = br.readLine();
for(int i = 0; i < 3 ; i ++ ){

if(staff[i].getStaId() == num){
System.out.println(staff[i].getStaId()+" "+staff[i].getStaname());
}else{
System.out.println("无此工号!");
}
}

}
}
怎么不能查询呀???

搜索更多相关主题的帖子: private public import 
2007-06-04 22:34
pity1115
Rank: 1
等 级:新手上路
威 望:2
帖 子:184
专家分:0
注 册:2006-9-15
收藏
得分:0 
for(int i = 0; i < 3 ; i ++ ){

if(staff[i].getStaId() == num){ //这里不要用 == 来判断,应该用 equals()
System.out.println(staff[i].getStaId()+" "+staff[i].getStaname());
}else{
System.out.println("无此工号!");
}
}

2007-06-04 23:18
快速回复:[求助]我这个程序出了什么问题??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019194 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved