Learn about the package in Java

xiaoxiao2021-03-06  14

Today, I'm discovering the problem of the package, I have tried it for a long time, I haven't said that it is clear, and I bought the book is too bad.

No way, continue learning, please teach the master to understand the meaning of the package, maybe just understand some of them.

First create a folder, named Test

Create a file in the catalog of Test CLIENT.JAVA

//Client.java

Package test;

Public Class Client

{

Public client () {}

Public void output ()

{

System.out.println ("this is package test");

}

}

Then go to the root directory to establish Dome.java

//Testmain.java

// Import test.client;

Import test. *;

Class Demo

{

PUBLIC DEMO () {}

Public static void main (string args [])

{

Client img = new client ();

Img.output ();

}

}

This is compiled with javac * .java

Run success. .

I feel some things, I am very happy, I understand the usage of IMPORT.

Pointing the package test in the package

This is to explain that this file is under Test's directory to facilitate program calls.

Import test. * is also an introduction of all defined classes in the TEST package

Import test.client; this is also a class that separates the definition in the CLIENT.

Learn Java in a few days, you can understand these, most of them are guided by master help

Thank you for your heart ~~

转载请注明原文地址:https://www.9cbs.com/read-48896.html

New Post(0)