Tuesday, 5 June 2012

Tuesday (June 5' 2012)

Today we were taught "How to Import a Package in ECLIPSE?" and about Interfaces . We can create as many classes in a package as we want and then by using that package in a separate class, we can call all those classes that have been previously created. Creating our own package saves memory, as the package stores all those classes inside it a separate buffer memory.
                                                         Using the keyword interface, you can fully abstract a class’ interface from its implementation.That is, using interface, you can specify what a class must do, but not how it does it.Using the keyword interface, you can fully abstract a class’ interface from its implementation.That is, using interface, you can specify what a class must do, but not how it does it.


Example:-

1.Creating a Package and Importing it in a separate class.

//Creating Package

package mypackage;
    public class Normal
{
        public void display()
        {
        System.out.println("Hello World");
        }
}

//Importing Package


import mypackage.*;
public class Myclass
{
    public static void main(String []args)
    {
        Normal n=new Normal();
        n.display();
    }
}
       

OUTPUT:
                    Hello World