{"id":2285,"date":"2020-04-01T17:57:57","date_gmt":"2020-04-01T17:57:57","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=2285"},"modified":"2020-04-23T15:30:41","modified_gmt":"2020-04-23T10:00:41","slug":"java-language-packages","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/java-language-packages\/","title":{"rendered":"Java Language packages"},"content":{"rendered":"<p><a href=\"https:\/\/www.h2kinfosys.com\/courses\/java-online-training-course-details\">Java language<\/a> has thousands of built-in classes. Java packages are a nice way to organize classes, interfaces, enumerations with similar functionality to groups. Packages help to avoid name conflicts. A code with packages is easier to maintain. They are the way of encapsulation. It can be compared to pieces of paper sorted in different folders by content. You don&#8217;t need to search for some information through all the papers. You will use a particular folder. The same with code. You need to tell in what package to look to find code. Therefore, packages make search and usage of classes, annotations, interfaces, enumerations easier.<br \/>\nThis code doesn&#8217;t compile, because we don&#8217;t know the package to search the class Date.<\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ImportExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(new Date());\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #3f7f5f; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\/\/ DOES NOT COMPILE<\/span><\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\"><span style=\"font-weight: 400;\">We will get an error that the Date cannot be resolved to a type. The compiler cannot find the class Date(). The code can be fixed if you provide the fully qualified name:<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ImportExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"> System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(new\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">java.util.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">Date());\u00a0<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\"><span style=\"font-weight: 400;\">Usually, your developer&#8217;s environment (Eclipse, NetBeans, etc) will give you a hint that you have missed an import. So, you can fix this error in another way. You will be able to compile after adding the import:<\/span><\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.Date;<\/span><\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ImportExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(new Date());\u00a0<\/span><\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p>As you can see, package names are hierarchical, sub realm names are separated by dots. To import then, we use the reserved word import. In the current case, we are importing just one class from the package java.util. But, there is also another way.<\/p>\n<h2><strong>Wildcard<\/strong><\/h2>\n<p>Let&#8217;s assume the situation that we need to import two classes from the same package. For example, ArrayList and Date from package java.util:<\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.Date;<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">java.util.ArrayList;<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ImportExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">ArrayList&lt;Date&gt;\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">list<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0=\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">new<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ArrayList&lt;Date&gt;();<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">list<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.add(<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">new<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0Date());<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">list<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.size());\u00a0<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">What if developers need to import 3 or more classes from the same package together? For this purpose they can use the wildcard *, that matches all classes in the package:<\/span><span style=\"font-weight: 400;\">What if developers need to import 3 or more classes from the same package together? For this purpose they can use the wildcard *, that matches all classes in the package:<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.*;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>This will import all classes from the package java.util, but not from child packages like java.util.concurrent, java.util.regex, java.util.stream, etc.<br \/>\nListing the classes used makes the code easier to read, but using the wildcard can shorten the import list. Including so many classes does not slow down your application. The compiler can figure out what is actually needed.<br \/>\nLet&#8217;s try to write all the imports together:<\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.Date;<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">java.util.ArrayList;<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.*;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>In this case, your developer&#8217;s environment will notify you that the import of java.util.* is redundant.<br \/>\nIt is illegal to use more than one wildcard in one import and it must be at the end. This does not compile:<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.*.*; \/\/DOES NOT COMPILE<\/span><\/p>\n<p>Also, this type of import is wrong:<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.ArrayList.*; \/\/DOES NOT COMPILE<\/span><\/p>\n<h2><strong>Naming Conflicts<\/strong><\/h2>\n<p>Using of packages has one more reason. Class names don\u2019t have to be unique across all of Java. There are two implementations for class the Date in<a href=\"https:\/\/www.h2kinfosys.com\/blog\/what-is-java\/\"> Java language<\/a>. They are in the packages java.util and java.sql.<br \/>\nIf you include both imports, your code would not compile:<\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.*;<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.sql.*;<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ConflictsExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(new Date());\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #3f7f5f; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\/\/ DOES NOT COMPILE<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">You can fix imports on the top of your class:<\/span><\/li>\n<\/ol>\n<p style=\"padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.Date;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">2. You can write a package that you want to use right in the code of your class:<\/span><\/p>\n<p style=\"padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(new java.util.Date());<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This code also doesn&#8217;t compile:<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import java.util.Date;\u00a0<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import java.sql.Date;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">This example will work even without imports:<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ConflictsExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">java.util.Date\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">date<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">;<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">java.sql.Date\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">sqlDate<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">;<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Consequently, when we have a naming conflict, we need to use a fully qualified class name for at least one of the classes.<\/span><\/p>\n<h2><b>Creating a New Package\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Let&#8217;s look at the new package creation. The directory structure on your operating system is related to the package name. Look at the example below.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Windows directory:<br \/>\n<\/span><span style=\"font-weight: 400;\">C:\\temp\\my\\test\\ClassA.java<br \/>\n<\/span><span style=\"font-weight: 400;\">The ClassA code:<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">package<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0my.test;\u00a0<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.util.Date;<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ClassA {\u00a0<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0printDate() {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(\u201cCurrent date: \u201d + new Date());\u00a0<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Our ClassA is inside package mytest. To define a package we have to use Java reserved word package. We have to use this statement before the class declaration and before all our imports. It has to be the very first line of code in our file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you want to import the ClassA you have to write:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">import my.test.ClassA;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">or<\/span><\/p>\n<p><span style=\"font-weight: 400;\">import my.test.*;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Assuming that a class ClassB is using our class ClassA. The class ClassB is in another package my.test.usage:<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">package<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0my.test.usage;\u00a0<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0my.test.ClassA;<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0ClassB {\u00a0<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0callClassA() {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(new ClassA().printDate());\u00a0<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s look at more examples to understand how packages correspond with the directory structure.<br \/>\nPackage: edu.mytest.subpackage.*<br \/>\nWindows path: C:\\temp\\edu\\mytest\\subpackage<\/p>\n<p>Package: com.example.myapplication.*<br \/>\nWindows path: C:\\temp\\com\\example\\ myapplication<\/p>\n<p>All packages and sub-packages have their own directory. Sub-packages are not imported by default. You have to import them explicitly. And vise versa, members of a sub-package have no access to its general package. They are considered as different packages. In other words, package my.test have to import package my.test.usage to have access to its <a href=\"https:\/\/www.h2kinfosys.com\/blog\/nested-classes-in-java\/\">java classes<\/a>. Similarly, package my.test.usage have to import package my.test.<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0StaticExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: transparent; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(Math.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">sqrt<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">(9));<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p>In code with static import we can remove class name before the method sqrt:<\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.lang.Math.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">sqrt<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">; \u00a0\/\/ STATIC IMPORT<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0StaticExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">sqrt<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">(9));<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<p>In case you want to use several static methods or variables from the same package you can use a wildcard:<\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">import<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: #ffffff; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0java.lang.Math.*; \/\/ STATIC IMPORT with WILDCARD<\/span><\/p>\n<p dir=\"ltr\" style=\"line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt; padding-left: 60px;\"><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">class<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0FutureExample {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">public<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">static<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #7f0055; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">void<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">\u00a0main(String[]\u00a0<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #6a3e3e; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">args<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">) {<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">sqrt<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">(9));<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">abs<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">(9));<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">PI<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">);<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">System.<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">out<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">.println(<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #0000c0; background-color: #ffffff; font-weight: bold; font-style: italic; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">E<\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: #ffffff; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">);<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\"><span class=\"Apple-tab-span\" style=\"white-space: pre;\">\u00a0 \u00a0\u00a0<\/span><\/span><span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><br \/>\n<span style=\"font-size: 10pt; font-family: Consolas,sans-serif; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">}<\/span><\/p>\n<h2><b>Build-in packages<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Java platform has a lot of build-in packages that are free to use.<\/span><\/p>\n<p><b>java.lang<\/b><span style=\"font-weight: 400;\"> is a basic package. It is allowed to use without an import statement. This package contains fundamental types and basic functionality. Here is some of them:\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">String, Object, Enum and wrappers for primitive types(Integer, Boolean, Byte, Double, etc);<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Class Math that contains methods for performing basic numeric operations (logarithm, square root, trigonometric functions, etc ) ;<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Interface Runnable and class Thread, as the ways to create a thread;<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">StringBuilder and Exception for operations over Strings;<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Basic exceptions: RuntimeException, NullPointerException, NumberFormatException, IndexOutOfBoundsException, ClassNotFoundException, IllegalArgumentException, etc.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Basic errors: Error, OutOfMemoryError, StackOverflowError, IllegalAccessError, AssertionError.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Basic annotations: Deprecated, Override, SuppressWarnings.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Popular interfaces: AutoCloseable, Cloneable, Iterable&lt;T&gt;, Comparable&lt;T&gt;.<\/span><\/li>\n<\/ul>\n<p><b>java.util<\/b> <span style=\"font-weight: 400;\">is a collection of data structure classes.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Classes of collections framework(Collection&lt;E&gt;, List&lt;E&gt;, Iterator&lt;E&gt;, Set&lt;E&gt;, Map&lt;K,V&gt;,\u00a0 ArrayList&lt;E&gt;, HashMap&lt;K,V&gt;, LinkedList&lt;E&gt; , etc).<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Some date and time facilities (Calendar, Date) .<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Internationalization and miscellaneous <a href=\"https:\/\/www.h2kinfosys.com\/blog\/design-a-class-in-java\/\">utility classes<\/a> (a string tokenizer, a random-number generator, and a bit array).<\/span><\/li>\n<\/ul>\n<p><b>java.io<\/b><span style=\"font-weight: 400;\"> is a package that provides facilities for system input and output through data streams, serialization and the file system (File, FileInputStream, FileOutputStream, Serializable, Console, InputStream, OutputStream, Closeable. Reader, Writer, etc).<\/span><\/p>\n<p><b>java.nio<\/b><span style=\"font-weight: 400;\"> defines buffers, which are containers for data.<\/span><\/p>\n<p><b>java.net<\/b><span style=\"font-weight: 400;\"> is a package that contains classes for implementing networking applications.<\/span><\/p>\n<p><b>java.security<\/b><span style=\"font-weight: 400;\"> contains classes and interfaces for the security framework ( key generation, encryption, decryption, networking operations, sockets, etc).<\/span><\/p>\n<p><b>java.sql <\/b><span style=\"font-weight: 400;\">is a package that provides the API for accessing and processing data stored in a data source. Usually, this package is using for relational databases.<\/span><\/p>\n<p dir=\"ltr\"><b>java.awt <\/b><span style=\"font-weight: 400;\">contains facilities for creating user interfaces and for painting graphics and images.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java language has thousands of built-in classes. Java packages are a nice way to organize classes, interfaces, enumerations with similar functionality to groups. Packages help to avoid name conflicts. A code with packages is easier to maintain. They are the way of encapsulation. It can be compared to pieces of paper sorted in different folders [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2736,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[58,458,459],"class_list":["post-2285","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorials","tag-java","tag-language","tag-packages"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=2285"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2285\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/2736"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=2285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=2285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=2285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}