Java simple object transfer, java object transfer

Source: Internet
Author: User

Java simple object transfer, java object transfer

Package Class. Member;

Public class Main {

Public static void main (String [] args ){

Member me = new Member (); // creates a Member object

MO mo = new MO (); // create a member operation object
Mo.mo (me); // call the input method of the member operation object and pass the member object to the member operation object

System. out. println ("\ n ***** member list ******");
System. out. println ("\ n \ t No. \ t points ");
Mo. member (me); // call the output method in MO to pass the member object to it
System. out. println ("\ n **************");
}
}

Package Class. Member;

Import java. util. collections;

/*
* Member
*/
Public class Member {

Int number; // number
Int integral; // points

}

Package Class. Member;

Import java. util. collections;

/*
* Member operation
*/
Public class MO {

Public void mo (Member me) {// input method to get a Member (Member) object named me (passed in the main method)

Keyboard input = new keyboard (System. in); // create a keyboard input object

System. out. print ("Member No.:"); // enter the number of the member number to the me object
Me. number = input. nextInt ();
System. out. print ("Member points:"); // enter the Member points to the integral of the me object.
Me. integral = input. nextInt ();

}

// In fact, the above input and the following output are bent around here, but they are different in different methods. They are passed through (Member me, then it is called by the main method.

Public void member (Member me) {// The Member number entered in the output and the integral method are followed by a member (Member) object named me (passed in the main method)

System. out. println ("\ t" + me. number + "\ t" + me. integral );

}

}

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.