# import, static import

* when using class, can skip package name.
* inform compiler the package where class is in.
* command+shift+O : automatically add import statement.
* class of java.lang package dont need import statement. ex) String, Object, System, Thread ...

```java
import (package).(class);
import (package).*;
```

* location : between package declaration and class declaration.

```java
package com.codechobo.book;

import java.text.SimpleDateFormat;
import java.util.*;

public class PackageTest{
    public static void main(String[] args) {
        Date today = new Date();
        SimpleDateFormat date = new SimpleDateFormat("yyyy/mm/dd");
    }
}
```

* Add package name if there are same class name and they are in different package.

```java
import java.sql.*;
import java.util.*;

public class ImportTest{
    public static void main(String[] args) {
        java.util.Date today = new java.util.Date();
    }
}
```

* **static import statement**

omitable class name when using static member.

```java
import static java.lang.Integer.*;//all of static member that means all of static variable and static methods
import static java.lang.Math.random;//all of static member of Math class.
import static java.lang.System.out;

out.println(random());
//System.out.println(Math.random());

out.println("Math.PI" + PI);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/java/import-static-import.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
