The first step of Java [8]

Source: Internet
Author: User
/*
Write a class called makeperson with a main () method that instantiates 2 person objects.
Initialize the attributes of one of the person objects by supplying parameters to it's constructor.
Instantiate the other person object with the default constructor (that does not accept any parameters ),
Then set it's attributes via the appropriate setter methods.
For each of the person objects, execute and print (system. Out. println () the results of all of
Getter methods and of the standardname (), formalname (), and casualname () methods.
*/

Public class makeperson
{
Public static void printinfo (person P)
{
System. Out. println ("title:" + P. gettitle ());
System. Out. println ("First name:" + P. getfirstname ());
System. Out. println ("Last Name:" + P. getlastname ());
System. Out. println ("nickname:" + P. getnickname ());
System. Out. println ("Age:" + P. getage ());
System. Out. Print ("Gender :");
If (P. getsex ())
{
System. Out. println ("male ");
}
Else
{
System. Out. println ("female ");
}
System. Out. println ("standard name:" + P. standardname ());
System. Out. println ("formal name:" + P. formalname ());
System. Out. println ("casual name:" + P. casualname ());


}

Public static void main (string [] ARGs)
{
Person DL = new person ("mr.", "ding", "Liang", "00", 20, true );
Person lly = new person ();
Lly. settitle ("ms .");
Lly. setfirstname ("Li ");
Lly. setlastname ("Liyuan ");
Lly. setnickname ("XX ");
Lly. setage (20 );
Lly. setsex (false );

Printinfo (DL );
Printinfo (lly );

}
}

 

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.