14_static_packages

Javaawtrectangle rectangle new javaawtrectangle import

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ention q༇  q༇  The name is lower case so it isn’t confused with a type or interface All official Java packages start with java or javax. java.awt.Rectangle rectangle = new java.awt.Rectangle(); Import the member's entire package (not recommended). n༆  import java.awt.*; Rectangle rectangle = new Rectangle(); q༇  Import the package member (recommended). n༆  import java.awt.Rectangle; Rectangle rectangle = new Rectangle(); 3 4/27/13 Summary n༆  Packages: q༇  q༇  q༇  n༆  Group together related Java types Help avoid name conflicts Provide access control Exceptions revisited n༆  n༆  n༆  Until now you only used predefined Java exceptions. You can write your own! Why would you want to do that? For more information: http://docs.oracle.com/javase/tutorial/java/package/index.html Savitch Chapter 9 Example public class DivideByZero Exception extends Exception { public DivideByZeroException() { super(“Divide by zero”); } public DivideByZeroException(String message) { super(message); } } 4...
View Full Document

Ask a homework question - tutors are online