140201129-贾杰峰
p173-6
class Date{
private String info;
private String identify;
public Date(String info)
{
this.info=info;
this.identify=identify;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public String getIdentify() {
return identify;
}
public void setIdentify(String identify) {
this.identify = identify;
}
}
public class SixWork {
public static void main(String[] args) {
Date infu=new Date("Java技术学习班20070326 MLDN 老师");
System.out.println("日期为:"+infu.getInfo().substring(9,17));
String str1="MLDN JAVA";
String newstr1=str1.replace("JAVA", "J2EE");
System.out.println("替换为:"+newstr1);
System.out.println("取出第8个字符为:"+infu.getInfo().charAt(7));
String str2=infu.getInfo().replaceAll("0", "");
System.out.println("清除所有0为:"+str2);
String str3=infu.getInfo().replaceAll(" ", "");
System.out.println("清除所有空格为"+str3);
infu.setIdentify("110225148605922654");
char b[]=infu.getIdentify().toCharArray();
for(int j=b.length-8;j<b.length;j++)
{
System.out.print(+b[j]);
}
}
}
9
class Book{
private String name;
private static int number=0;
private int money;
private static int ceshu;
private String count;
public Book(String name,int number,int money,int ceshu)
{
this.name=name;
this.number=number;
this.money=money;
this.ceshu=ceshu;
this.count=""+number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static int getNumber() {
return number;
}
public static void setNumber(int number) {
Book.number = number;
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public static int getCeshu() {
return ceshu;
}
public static void setCeshu(int ceshu) {
Book.ceshu = ceshu;
}
public String information()
{
return "书名为:"+this.name+"\n编号为:"+this.count+"\n价格为:"+this.money+"\n册数为:"+this.ceshu;
}
}
public class NinethWork {
public static void main(String[] args) {
Book book[]={
new Book("zs",1,12,46),new Book("ls",2,32,80),new Book("tbw",3,42,95)
};
int sum=0;
for(int j=0;j<book.length;j++)
{
sum=sum+book[j].getCeshu();
System.out.println(book[j].information());
}
System.out.print("总册数为:"+sum);
}
}