class Boss{
private String name;
private String sex;
private int age;
public Boss(String name,String sex,int age){
this.name = name;
this.sex = sex;
this.age = age;
}
public void display(){
System.out.println("姓名"+this.name+"性别"+this.sex+"年龄:"+this.age);
}
public static void main(String[] args){
Boss boss = new Boss("zs","男",12);
boss.display();
}
}
2.handleStr:
public String handleStr(String str){
Char[] ccs =str.match("\d");
String.valueOf(ccs);
}
package ab.test;
public class HandleStr {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s = "hskhd3277893hlk223hlki";
String resultStr = handleStr(s);
System.out.println(resultStr);
}
private static String handleStr(String str) {
// TODO Auto-generated method stub
char[] cs = str.toCharArray();
StringBuffer bf = new StringBuffer();
for (char c : cs) {
//anscii 48--57(0--9)
if (c >= 48 && c <= 57) {
bf.append(c);
}
}
String reverseStr = bf.reverse().toString();
return reverseStr;
}
}