Syntax

Java Import a Class Syntax

In Java, import a class: imports a class from a package — import java.util.List;

Quick Answer

Syntax
import java.util.List;
JavaSyntax

Import a Class

Code example
import java.util.List;

Imports a class from a package.

Learn More

How to import a class in Java

  1. Open your Java file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Java Import a Class Syntax

Use import java.util.List;.

Related Syntax References

Frequently asked questions

What is the Java syntax for import a class?

Use this pattern: import java.util.List;

Can I copy this Java code example?

Yes. Use Copy code and adapt the example to your program.

Is this Java syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify