AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-basics: why java.lang package is being imported by default

why java.lang package is being imported by default.

corejava x 352
basics x 170
Posted On : 2016-11-07 17:49:56.0
profile sudhir kumar - anyforum.in sudhir kumar
1300
up-rate
5
down-rate

Answers


the java.lang package is imported implicitly. Java is a pure object oriented programming language where code is written in form of classes. These class components are called types. Types in Java come in two flavors: built-in or primitive types and types from components. Primitive types can be used directly while component types must usually be ordered from a library by importing them from the appropriate package. The technical term for ordering a component from a library is bringing a component into scope. The Java standard libraries include java.lang package by default, which contains a number of components that are used very commonly in Java programs. Java is useless without much of the functionality in java.lang, that´s why java.lang is implicitly imported by the compiler for all programs.

However, one can import the same package or same class multiple times. If you explicitly import java.lang in your program then neither compiler nor JVM complains anything about it, but JVM internally loads the required class only once, no matter how many times you import the same class.

Third, the current package is the one in which the class in execution is defined. Current Java package is automatically imported by Java compiler.

Posted On : 2016-11-10 22:23:07
Satisfied : 0 Yes  2 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188221600
Reply This Thread
up-rate
0
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in