- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Do I need to import the Java.lang package anytime during running a program?
No, java.lang package is a default package in Java therefore, there is no need to import it explicitly.
i.e. without importing you can access the classes of this package.
If you observe the following example here we haven’t imported the lang package explicitly but, still we are able to calculate the square root of a number using the sqrt() method of the java.lang.Math class.
Example
public class LangTest { public static void main(String args[]){ int num = 100; double result = Math.sqrt(num); System.out.println("Square root of the number: "+result); } }
Output
Square root of the number: 10.0
- Related Articles
- Is there a need to import Java.lang package while running Java programs?
- How do I import all the submodules of a Python namespace package?
- To work with SciPy, do I need to import the NumPy functions explicitly?
- What environment variables do I need to set up before I start running Java programs on my machine?
- Difference between import and package in Java?
- Can I import same package twice? Will JVM load the package twice at runtime?
- How to import Pandas package?
- Can we define a package after the import statement in Java?
- How do I write package names in Java?
- How to import classes from within another directory/package in Java?
- Why we do not import a package while we use any string function?
- How to import everything from a python namespace / package?
- How do you dynamically add Python modules to a package while your programming is running?
- How do I create a namespace package in Python?
- How to run Java package program

Advertisements