Java import statements can only come after the PACKAGE declaration statement if any. The keyword used to import a Java package or Java class is " import". Syntax: package PACKAGE_NAME //very first statement in a class file All the classes in the java file belong to the mentioned PACKAGE-NAME. The line number may be anyone like 1, 2, 3 or any. A package declaration statement should be the very first statement in a Java class file. The keyword used to declare a package is " package". The computer may run any OS (Operating System like Windows, Unix or Linux). In simple words, a Java package is Directory on a computer file system. The members of an outside House may reuse names without collision. The concept of Java packages is similar to a House containing members whose names are unique. Development teams can maintain individual packages so that they do not need to worry about Same name collisions for classes and interfaces. Let us learn more about a Java Package, its rules and usage with examples in this Last Minute Java Tutorial.Īll Java classes, Abstract classes and Interfaces can use these package and import statements. Packages allow us in Visibility and Namespace management of Java Classes, Variables and Methods. Java Packages are containers for CLASS files with a folder structure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |