Java-based package example

Source: Internet
Author: User
Yesterday's 3rd lecture mainly talked about the concept of OOP and the usage of package. The latter is new to use. The following is the assignment, which is relatively simple for newbie reference only, the instructor requested to use JBuilder, but that stuff is not open-source after all. Although its level is poor, there is no difference between open-source and non-open-source ~ However, I agree with open source in spirit.
~ Because the open-source community is our hope that we can beat back to Microsoft.
The weather is still a bit hot today. Rugby is ready for the evening ~~ Lets fight... Wait a minute ~ Fight for what?

/*
Create a sub-package named child. Its basic package name is parent. The sub-package should contain a location class.
The location class contains a method named disp () used to display messages of "Everything is meaningless.
Create a class named parenttest to import the sub-package and call the disp () method of the location class.
Note: The package is a folder. Take parent. Child as an example to compile the location. Java location. Class file.
Put it in parent/child/location. Class
*/
// Package containing location class
Package parent. Child;
Public class location {

Public void disp ()
{
System. Out. println ("Everything is meaningless ");
}
}

// Parenttest
Import parent. Child. location;
Class parenttest {
Public static void main (string [] ARGs)
{
Location A = new location ();
A. disp ();
}
}

 

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.