如何在类中设置性别限制

如何在类中设置性别限制

if(studentSex!=‘’男‘’|studentSex!=‘’女‘’)
        this.studentSex=‘’男‘’;
else
        this.studentSex=studentSex;

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
慕姐917595 2018-11-10 22:47:35
if(studentSex.equals("男")||studentSex.equals("女"))
    this.studentSex=studentSex;
else
    this.studentSex="男";


  • if(studentSex.equals("男")||studentSex.equals("女")) this.studentSex=studentSex; else this.studentSex="男";
    2018-11-10 22:48:59
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师