Java Simple Object passing

Source: Internet
Author: User

Package class.member;

public class Main {

public static void Main (string[] args) {

Member me = new Member (); Create a Loyalty Object

Mo mo = new Mo (); Create a Member Action object
Mo.mo (Me); Invoke the input method of the member operation object and pass the member object to the Member action object

SYSTEM.OUT.PRINTLN ("\n* * * * member List * * * * * *");
System.out.println ("\n\t number \t\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.Scanner;

/*
* Membership Category
*/
public class Member {

int number; Number
int integral; Integral

}

Package class.member;

Import Java.util.Scanner;

/*
* Member Action Class
*/
public class Mo {
   
    public void MO (Member me) {&N bsp;  //Input Method    next member (Member) object   name me (passed in the Main method)
        
        Scanner input = new Scanner (system.in);    //Creating keyboard Input Objects
        
         System.out.print ("member Number:");   //Enter the number of the member to the Me object
         Me.number = Input.nextint ();
        System.out.print ("Member points:");   // Enter loyalty points to the Me object integral
        me.integral = Input.nextint ();    

}

In fact here detours to see the above input with the output below, but in different methods is not the same, it is passed through (Member me), and then by the Main method call

public void member (member me) {//Output input membership number and integral method by a member (Member) object name is me (passed in the Main method).

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

}

}

Java Simple Object passing

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.