I\'ve recently switched from working in PHP to Java and have a query. Want to emphasise I\'m a beginner in Java.
Essentially I am working in File A (with class A) a
Java has classloader mechanism that is kind of similar to PHP's autoloader. This means that you don't need anything like a include or require function: as long as the classes that you use are on the "classpath" they will be found.
Some people will say that you have to use the import statement. That's not true; import does nothing but give you a way to refer to classes with their short names, so that you don't have to repeat the package name every time.
For example, code in a program that works with the ArrayList and Date classes could be written like this:
java.util.ArrayList list = new java.util.ArrayList<>();
list.add(new java.util.Date());
Repeating the package name gets tiring after a while so we can use import to tell the compiler we want to refer to these classes by their short name:
import java.util.*;
....
ArrayList list = new ArrayList<>();
list.add(new Date());