Please tell me what is a package?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please tell me what is a package??

I want to know what is default access specifier for classes

30th Dec 2017, 12:37 PM
Sufal Chhabra
Sufal Chhabra - avatar
4 Answers
+ 5
A Java package is a mechanism for organizing Java classes into namespaces similar to the modules of Modula. Java packages can be stored in compressed files called JAR files, allowing classes to execute faster as a group rather than one at a time. Programmers also typically use packages to organize classes belonging to the same category or providing similar functionality Java provides a default specifierwhich is used when no access modifier is present. Any class, field, method or constructor that has no declared access modifier is accessible only by classes in the same package. The default modifier is not used for fields and methods within an interface. Java provides a default specifierwhich is used when no accessmodifier is present. Any class, field, method or constructor that has no declared access modifier is accessible only by classes in the same package. The default modifier is not used for fields and methods within an interface. https://stackoverflow.com/questions/16164902/what-is-the-default-access-modifier-in-java
30th Dec 2017, 12:47 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
A package is a group of classes sometimes group of packages. And the default access specifier for classes is "default". If we do not mention the default access specifier for the classes then the compiler takes it under default accessibility. If a class is declared as default then that class is accessible only in the package in which it is created.
12th Jan 2018, 12:25 AM
Nashat
Nashat - avatar
0
okey got it but SOLOLEARN says default makes class accessible in the same package. what does that mean?
30th Dec 2017, 12:43 PM
Sufal Chhabra
Sufal Chhabra - avatar
0
thank you Gawen Steasy
30th Dec 2017, 1:00 PM
Sufal Chhabra
Sufal Chhabra - avatar