This site javatpoint is very useful for programming languages like JAVA,PYTHON,C,C++, Data Structures etc.Java learning Concept also provides technical materials , which are related to latest technologies. We provides very easy lectures to our viewers from beginning to advance level.We focus logical content instead of theoretical content.

Saturday, 28 October 2017

PACKAGE IMPORT INSIDE PACKAGE

PACKAGE IMPORT INSIDE PACKAGE:

Given that packages exist and and are good mechanism for compartmentalized diverse classes from each to see why all the built in Java classes are stored in packages. There are no Core Java classes in the unnamed default package, all of the standard classes are stored in some named package. Since classes within package must be qualified with their package name or names, it could become tedious to type in the long separated package path name for every class you want to use. For this reason, Java including the import statement to bring certain classes,or entire packages, into visibility. Once Import,a class can be referred to directly, using only it's time. 
The Import statement is a converse to the programmer and is not technically needed to write a complete Java programs. 


Example 




package p1;
import java.util.Scanner;
class X
{
int a,b,c;
void getdata()
{
System.out.println("enter two number");
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
b=sc.nextInt();
}
void sum()
{
c=a+b;
System.out.println(c);
}
}
class Y1 extends X
{
void multi()
{
c=a*b;
System.out.println(c);
}
public static void main(String args[])
{
Y1 ob=new Y1();s
ob.getdata();
ob.sum();
ob.multi();
}
}


OUTPUT:
                       Enter two number
                        10
                         5
       //total        15
        //multi       50
Adbox