publicclassExample{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);//显示菜单System.out.println("请选择性别:1-男2-女");try{intsex=input.nextI...
system.out.println("姓名"+name+“性别:”+temp;}
publicclassTest{publicstaticvoidmain(String[]args){Stringstr;intage=21;if(age>18){str="你是大人";}else{str="你是小孩";}System.out.println(str);//用三目运算符,简洁代码Stringstr2=age...
1、单独创建一个客户类Customer,里面分别定义属性:客户姓名、客户年龄、客户是否会员,创建一个用来操作Customer客户类的CustomerBiz客户操作类,接下来的代码编写,都是在CutomerBiz客户操作类中进行。1、在CustomerBiz客户操作类...
男女你可以先定义一个JCheckBox,把JCheckBox添加到a里面你这样直接添加相当于添加字符串,但是addItem()里面是需要添加组件而不是字符串
System.in);Stringsex=s.next();if(sex.toLowerCase().equals("m"))System.out.println("男性");elseif(sex.toLowerCase().equals("n"))System.out.println("女性");elseSystem
;Stringbirth=id.substring(6,14);Stringsex=id.substring(16,17);if(Integer.parseInt(sex)%2==0){sex="女";}else{sex="男";}System.err.println("生日:"+birth+"性别"+sex);}..
classTest{publicstaticvoidmain(String[]args){Genderg=Gender.MALE;System.out.println("性别:"+g);}}这样的另一个好处是,你要添加其他性别,如变性啊,Les啊,Gay啊都很方便的,。
设置为一个group,然后在这个组里做两个单选框,男、女。注意:一定要在同一个组里面,2楼的可以参考一下,不过少了个分组,不行的哦。不论是网页还是程序,都必须在同一组的。当然,你还可以增加人妖这一项!哈哈。。
packagehelloworld;importjava.awt.*;importjavax.swing.*;//importcom.borland.jbcl.layout.XYLayout;//importcom.borland.jbcl.layout.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;p