0% found this document useful (0 votes)
22 views1 page

Java Unit 9

Uploaded by

anonymous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Java Unit 9

Uploaded by

anonymous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

☠☠☠Understanding Core Packages☠☠☠

1.Using java.lang Package: java.lang.Math:


The `java.lang` package is a default package that is automatically imported into every
Java program. It contains fundamental classes and interfaces that are essential to the
Java programming language. One of the classes in this package is `java.lang.Math`, which
provides a set of mathematical operations such as trigonometric, logarithmic,
exponential, and other common mathematical functions.

You can use `Math` class methods to perform basic mathematical calculations such as
rounding numbers, generating random numbers, finding the absolute value, finding the
maximum and minimum of two numbers, and more. For example, you can use the
`Math.sqrt()` method to calculate the square root of a number or the `Math.abs()`
method to find the absolute value of a number.

2.Using java.util package:


The `java.util` package provides a variety of useful classes and interfaces for working
with collections, dates, and other common utilities. Some of the commonly used classes
and interfaces in this package are:

Collections: This class provides various static methods for working with collections such
as sorting, searching, and manipulating collections.

List: This is an interface that represents an ordered collection of elements that can
contain duplicates.

Set: This is an interface that represents a collection of unique elements with no


duplicates.

Map: This is an interface that represents a mapping between a key and a value.

Date and Time API: This package provides classes and interfaces for working with dates
and times, such as LocalDate, LocalTime, and LocalDateTime.

Scanner: This class provides methods for reading input from various sources such as the
console, files, and strings.

You might also like