Properties in the "JAVA" call class

Source: Internet
Author: User

classperson{String name; intAge ;        String like; voidsetName (String name) { This. Name =name; }        voidSetage (intAge ) {         This. Age =Age ; }        voidsetlike (String like) { This. like=Like ; }        voidTalk () {System.out.println ("I am:" + name + ", this year:" + Age + "years," + "like:" +Like ); }} Public classclasswork{ Public Static voidMain (string[] args) {person P=NewPerson (); P.setname ("Xiao Ming"); P.setage (20); P.setlike (Music);    P.talk (); }}

classBook {String title; DoublePrice ;  Public voidPrintinfo ()//Book Information{System.out.println ("The name of the book:" + title + ", Price:" +Price ); }} Public classwork2{ Public Static voidMain (String args[]) {book Booka=NewBook (); Book BOOKB=NewBook (); Booka.title= "Program Design" ; Booka.price= 40.7 ; Bookb.title= "C Language" ; Bookb.price= 33.9 ; BOOKB=Booka;        Booka.printinfo ();            Bookb.printinfo (); }}

classBooks {PrivateString title; Private DoublePrice ; String Pub= "Every day Wonderful publishing house" ;  PublicBooks (String title,DoublePrice ) {         This. title =title;  This. Price =Price ; }       PublicString GetInfo () {return"Book Name:" + This. Title + ", Price:" + This. Price + "yuan, publishing house:" + This. pub; }} Public classwork3{ Public Static voidMain (String args[]) {Books B1=NewBooks ("Java Development Combat Classic", 59.8) ; Books B2=NewBooks ("Java Web Development Combat Classic (Basic)", 49.9) ; Books B3=NewBooks ("Android Development Combat classic", 68) ;        System.out.println (B1.getinfo ());        System.out.println (B2.getinfo ());              System.out.println (B3.getinfo ()); System.out.println ("----------------------Publishing house renamed after-------------------------") ; B1.pub= "Wonderful Daily Press" ; B2.pub= "Wonderful Daily Press" ; B3.pub= "Wonderful Daily Press" ;        System.out.println (B1.getinfo ());        System.out.println (B2.getinfo ());    System.out.println (B3.getinfo ()); }}

Properties in the "JAVA" call class

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.