reading-notes


Project maintained by sanaa-almoghraby Hosted on GitHub Pages — Theme by mattgraham

Packages and Import

Package = directory. Java classes can be grouped together in packages. A package name is the same as the directory (folder) name which contains the .java files. You declare packages when you define your Java program, and you name the packages you want to use from other libraries in an import statement.

import FAQ

Q: Is the order of the imports important?
A: No. Group them for readability.
Q: I've imported java.awt.*, why do I also need java.awt.event.*?
A: The wildcard "*" only makes the classes in this package visible, not any of the subpackages.

A Guide to Java Loops

Here are the types of loops that we can find in Java:

1.Simple for loop ![](https://media.geeksforgeeks.org/wp-content/uploads/20191108131134/For-Loop.jpg)

2.Enhanced for-each loop ![](https://1.bp.blogspot.com/-sbcx1gZN5Zs/XPeFw4TNCdI/AAAAAAAAU9A/d37MRLD2RsMX7DyiFc9DglQn27VtAvVZACLcBGAs/w1200-h630-p-k-no-nu/The%2BEnhanced%2Bfor%2Bloop%2Bin%2BJava%2B-%2BHostmann%2Bbook.png)
3.While loop

4.Do-While loop