Sometimes when I view source java code I notice some files placed in another package besides the default one but have not understood when or why this practice is used. Are there situations where you must or mustn't use separate packages? Anyone care to explain please?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
When to Use Separate package in java:
Lets us take an example in favor of this question.
Suppose you have an java program that deals with the database connectivity also it need two separate threads to perform this task and also it need some arraylist to store the database information that has been retrieved from the database. in this case it's very easy to use package.If I need database package I know that where it it I will simply import my
java.sql package
If I have to handle with thread I will use
java.lang.Thread
package. And I have to deal with arraylist then I will use myjava.util
package. Think how it is simple to just import package based on your need.e.g
Now I can use this package into by another class