java培训吧 关注:116,350贴子:396,615
  • 0回复贴,共1

java封装相关的问题为什程序执行完之后会有false显示

取消只看楼主收藏回复

public class Customer01{
private boolean sex ;
public void setSex(boolean sex1){
if(sex1==true){
System.out.println("该客户性别为男");
}else{
System.out.println("该客户性别为女");
}
}
public boolean getSex(){
return sex;
}
public class OOTest03{
public static void main (String [] args){
Customer01 c = new Customer01();
c.setSex( false );
System.out.println(c.getSex());
}
}


1楼2015-10-11 19:57回复