• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Question

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between Package and Interface.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

I'm moving your question to Java in General (Beginner), where it will be more on-topic and likely to get an answer.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An Interface is more like (not exactly) an Abstract Class. Its methods are not implemented and its variables are constants.

A Package is more like (not exactly) a Path to the class. For example, if a class is in a package com.javaranch.common, it may be found in a directory structure like this:
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another way of looking at it is like this:

1. A "package" is a namespace. It lets you distinguish between two different classes from two different places that both happen to have the same name (e.g. "com.javaranch.common.Print" vs. "org.someneattoolkit.print").

2. An "interface" is a contract. Any class which "implements" a given interface "promises" to provide each of the methods - with exactly the specified arguments - to any client which invokes it.

'Hope that helps .. PSM
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic