
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is there a need to import Java.lang package while running Java programs?
The java.lang package is the default package in Java, by default, it will be imported. Therefore, there is no need to import this package explicitly. i.e. without importing you can access the classes of this package.
Example
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.
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 Questions & Answers
- Do I need to import the Java.lang package anytime during running a program?
- How do you dynamically add Python modules to a package while your programming is running?
- Where and how is import statement used in Java programs?
- Is there a need to insert auto_increment column values in MySQL while using INSERT statement?
- How to import Pandas package?
- Difference between import and package in Java?
- Why we do not import a package while we use any string function?
- What environment variables do I need to set up before I start running Java programs on my machine?
- How to import everything from a python namespace / package?
- Can we define a package after the import statement in Java?
- How to import classes from within another directory/package in Java?
- How to manipulate figures while a script is running in Python Matplotlib?
- What is a predefined package in Java?
- Why there is not do...while loop in Python?
- Is there a way to create a MySQL “alias” while creating a VIEW?
Advertisements