"1"
1 Public classJava401 {2 Public Static voidMain (string[] args) {3String str1= "Java Technology workshop 20070326";4String str2= "Java Technology workshop 20070326 MLDN Teacher";5String str3= "330521199601221711";6System.out.println (Str1.substring (10,18));7System.out.println (Str1.charat (7));8System.out.println (Str1.replaceall ("0", "" "));9System.out.println (Str2.replaceall ("", ""));TenSystem.out.println (Str3.substring (6,14)); OneString str= "Mldn JAVA"; AString Newstr=str.replaceall ("JAVA", "ee"); -SYSTEM.OUT.PRINTLN ("Result after replacement:" +newstr); - } the}
Program Run Results
"2"
1 classbook{2 PrivateString name;3 Private intID;4 Private floatPrice ;5 Private Static intNum=12;6 Private Static intCount=0;7 PublicBook () {8count++;9 This. id=count;Ten } One PublicBook (intID) { A This. id=ID; - } - Public intgetId () { the return This. ID; - } - PublicBook (String name,floatPrice ) { - This. name=name; + This. price=Price ; - This. num=num; + } A Public voidsetName (String name) { at This. name=name; - } - PublicString GetName () { - return This. Name; - } - Public voidSetprice (floatPrice ) { in This. price=Price ; - } to Public floatGetPrice () { + return This. Price; - } the Public voidSetnum (intnum) { * This. num=num; $ }Panax Notoginseng Public intGetnum () { - return This. Num; the } + } A Public classJava402 { the Public Static voidMain (string[] args) { +Book book[]=NewBook[6]; -book[0]=NewBook ("Melancholy Grocery store", 36.9f); $book[1]=NewBook ("The Secret of the Detective", 26.6f); $book[2]=NewBook ("White Nights", 67.9f); -book[3]=NewBook ("The Meteor Trip", 52.5f); -book[4]=NewBook ("The Detective's Code", 62.3f); thebook[5]=NewBook ("The Blade of hesitation", 13f); - for(inti=0;i<book.length;i++){WuyiSystem.out.println ("No.:" +NewBook (). GetId () the+ "\ t title:" +Book[i].getname () -+ "\ t Price:" +Book[i].getprice () Wu+ "\ t quantity:" +book[i].getnum ()); - } AboutSystem.out.println ("Total Books:" + (NewBook (). GetId ()-1) *book[1].getnum ()); $ } -}
Program Run Results
4th Time Java Job +lsyang