4th Time Java Job +lsyang

Source: Internet
Author: User

"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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.