Java Reference Data Type instance

Source: Internet
Author: User

1  Public class   Car {2    String color; 3     String Pinpai; 4     Double size;     5 }
1 class Dianfanbao {2        String Pinpai; 3         Double Daxiao; 4         String color;     5 }
1 class Student {2    String name; 3     int Age ; 4     String sex; 5 }
1 classZonghe {2      Public Static voidMain (string[] args) {3Student Stu =Newstudent ();4Stu.name = "Zhang San";5Stu.age = 13;6Stu.sex = "Male"; 7Dianfanbao DFB =NewDianfanbao ();8Dfb.pinpai = "Nine Yang";9Dfb.daxiao = 1.8;TenDfb.color = "Red"; OneCar CA =Newcar (); ACa.pinpai = "Volkswagen"; -Ca.color = "BLACK"; -Ca.size = 18; theSystem.out.println ("The Student's sex is:" +stu.sex); -SYSTEM.OUT.PRINTLN ("Student's name is:" +stu.name); -SYSTEM.OUT.PRINTLN ("Student's age is:" +stu.age); -System.out.println ("The brand of the car is:" +Ca.pinpai); +SYSTEM.OUT.PRINTLN ("The color of the car is:" +ca.color); -System.out.println ("The size of the car is:" +ca.size); +System.out.println ("Rice Cooker Brand:" +Dfb.pinpai); ASystem.out.println ("Rice Cooker Size:" +Dfb.daxiao); atSystem.out.println ("Rice Cooker Color:" +dfb.color); -     } -}

The above example encapsulates 3 classes and then incoming the value in a main method and calls it, because the class that we create ourselves is in the same folder, so there is no import package, and if you call a Java-provided class, you need to import the package and then call it.

Java Reference Data Type instance

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.