Java class object array declaration and initialization

Source: Internet
Author: User

Java is a purely object-oriented language. The class is its important constituent unit. Then, in actual programming, we will customize some classes, such as the point

<span style= "FONT-SIZE:14PX;" >public class Point {public Point () {lat=0.0; lng=0.0;} Public double Getlat () {return Lat;} Public double getlng () {return Lng;} public void Setlat (double pLat) {Lat=plat;} public void setlng (double plng) {lng=plng;} Private double lat;private double Lng;} </span>
For example, such an entity class, we often want to use its object array. However, the Declaration and initialization of an object array in Java differs from the Declaration and initialization of its fixed type. Please see below.

<span style= "FONT-SIZE:14PX;" >//init class Pointpoints=new point[totalpoints];//statement of Points array//initing for (int i=0;i<totalpoints; i++) {points[i]=new point ();} </span>



Java class object array declaration and initialization

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.