How to Import Classes in Java

104 34
    • 1). Identify the name of the package that contains the Java class(es) you need. Java packages are similar to libraries in other programming languages. A good resource for finding which package contains a given class in the standard Java Platform is Oracle's "API Specification" Web document (see Resources).

    • 2). Import one class at a time by including a fully-specified "import" statement at the beginning of your Java program. For example, "import java.net.InetAddress;" imports only the InetAddress class.

    • 3). Import a family of related classes by including a single wildcard "import" statement at the beginning of your code. For example, "import java.net.*;" imports all classes that share the "java.net" prefix, such as InetAddress, Proxy and URL.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.