Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Java Packages

No description

Aihoa Le

on 25 July 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Java Packages

Java Packages
Why would we want to package Java files?
It makes it easier to tell which files are related.
How do we make packages?
With a package statement. You pick a name for your package and put the package statement above every source file that you are going to place in that package.

How do we use packages?
To use a member of a package within its package, simply call it like you would any other method or class.
What's a "package"?
In real life:
In Java:

A package is a way to group and bundle related java files (i.e., interfaces and classes).

It makes it easier when you're looking for a file that has a specific function.
It helps you avoid naming conflicts.
You can make files with identical names and there won't be a problem if they're in different packages.
For example if you have classes called "Dog", "Cat", "Cow", and "Zebra", it would make sense to put them in a package called "Animal" since they are all animals.
We know to call methods from the Math class when something calls for absolute value, the PI constant, the sin and cos functions, etc.
Packages help you control what accesses your files.
You can have the types within your packages have access to one another and restrict types outside the package from accessing the types within it.
package Animal;
How do we use packages?
To use a member of a package outside of its package, we need to import the package or the specific member:

import packageName*;
import packageName.memberName;

For Example:
import java.util.*;
import java.util.ArrayList;
Full transcript