Computer Science, asked by chiekou, 1 year ago

library function in java......explain in detail

Answers

Answered by Anonymous
6

Library Classes:- These are the predefined classes provided by Java system present in packages. These classes contain related library functions like String Math, etc. All the library classes belong to some package.

Library Functions:- These are the inbuilt functions present in Java library classes, provided by Java system to help programmers to perform their task in an easier way.

Library Classes are to be included in java program using a package.

Package:-Packages are collection of classes or subclasses. We have different packages defined to import or include the classes required in the Java program.

The different packages are:

1. io package:- It includes all the classes related to input/output.

2. lang package:- It include all the statements and functions common to all program.For eg we have,System.out.println ,main function etc used in all the program.Also lang package is the default package which is by default imported in all the java program.But we can also include this package explicitly.

3. util package:- It includes all the utility classes.For eg like date and time.

4. awt package:- It includes all the classes related to graphical design.

5. sql package:- It includes classes of the database connectivity.

6. applet package:- It includes all the classes related to Internet programming.

7. net package:- It includes all the classes related to networking.

Import Statement:-

This statement is used to add or include the classes related to the package. Import statement should be the first statement of the program.

How to import a package:

Syntax:
Import java.lang.*;
Import java.io.*;

Program to take the input from the user to print the Name and Age of the Employee.

We use BufferedReader class which is in io package to take the input and read it and print the output on the screen.


how to import pacage in java.io

class Employee{public static void main(String args[])throws IOException  // *{ InputStreamReader ir=new InputStreamReader(System.in);  // function to take input from user.BufferedReader br=new BufferedReader(ir); // class to read user input.String name;int age;System.out.println("Enter the Name");name=br.readLine();  // function defined in buffered class to take input from user as a stringSystem.out.println("Enter the Age");age=Integer.parseInt(br.readLine());  // converting default string input to integerSystem.out.println("Name is " + name);System.out.println("Age is "+ age); }}
Similar questions