im new to java.
the standard code that is created after i created a new project in netbeans is:
package helloworldapp;
public class Main {
public static void main(String[] args) {
int[] array = new int[10];
array[9] = 1;
System.out.println(array[9]);
}
}
so you see that it uses the System class, but i dont see that class has been imported. Is there another code somewhere that does that? How can i use it if its not imported.
The System class is, along with everything else in java.lang, imported automatically. Other classes you probably use that are automagically imported include String and Exception.
Additional info:
How can i use it if its not imported.
you can use any class in another package, without importing it, by using the fully qualified name. Example:
java.util.Date now = new java.util.Date();
instead of
import java.util.Date; // or java.util.*;
...
Date now = new Date();
Update:
import is only used at compile time to determine the fully qualified name of classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With