An array of objects to learn Java tutorials

Source: Internet
Author: User

Learn to program the Java Tutorial Object array published, welcome to visit through the xuebiancheng8.com

What is an array of objects, an array of objects, as the name implies.

First define an object

public class student{

Private String username;

private String password;

Setter,getter ....

}

As shown above, a student object is defined

3 Student objects to join now what do we do?

Student stu1 = new Student ();

Student STU2 = new Student ();

Student stu3 = new Student ();

Instantiate the above three objects.

If there are now 100 objects to do, it is not necessary to instantiate 100 objects, so it is too troublesome, this time you can use the object array

Student [] stu = new student[100];

There are 100 student in this array.

If you put a student in the first place, you can do this.

Stu[0] = new Student ();

If you put a student in the second position, you can do this.

STU[1] = new Student ();

If it's in the third position,

STU[2] = new Student ();

When the assignment is complete, you can

STU[0] subscript to access.

This time is the same as the usage of ordinary arrays.

For more information, please visit xuebiancheng8.com.

The specific URL is

Http://xuebiancheng8.com/play/goodgoodstudy_126_daydayup.html

An array of objects to learn Java tutorials

Related Article

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.