Joel Adams and Jeremy Frens Calvin College

Slides:



Advertisements
Similar presentations
1 Packages: Putting Classes Together. 2 Introduction The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance)
Advertisements

1 G54PRG Programming Lecture 1 Amadeo Ascó Adam Moore 29 Organising Code: Packages & Archives.
Processing and Java David Meredith
Packages Sudhir Talasila Preeti Navale. Introduction Packages are nothing more than the way we organize files into different directories according to.
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
James Tam Java Packages Packages, a method of subdividing a Java program and grouping classes.
Package and Import Yoshi. Michael How many “Michael” in this world? When we only say “Michael”…who? So we have the last name – Michael Jordan – Michael.
More Java: Encapsulation, Getters, Setters, Anonymous Class 1 CS300.
JAVA PROGRAMING LANGUAGE. Content of Java 2 SDK  Development Tools (In the bin subdirectory.) Tools and utilities that will help you develop, execute,
Programming in Java CSE301 Half Lecture Harry Erwin, PhD University of Sunderland.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
James Tam Java Packages Packages, a method of subdividing a Java program and grouping classes.
Chapter 3 Using Classes and Objects. 2 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used.
Unit 051 Packages What is a Package? Why use Packages? Creating a Package Naming a Package Using Package Members Managing Source and Class Files Visibility.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
References, Aliases, Garbage Collection and Packages Packages and Importing Classes Reading for this Lecture: L&L, Familiarize yourself with.
Chair of Software Engineering Beyond Eiffel these slides contain advanced material and are optional.
University of Limerick1 Work with API’s. University of Limerick2 Learning OO programming u Learning a programming language can be broadly split into two.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Packages.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
Object Oriented Programming in Java Habib Rostami Lecture 5.
Java 2 More Java Then Starbucks ;-). Important Terms Primitive Data – Basic, built-in values (characters & numbers) Data Type – Used to talk about values.
Objects and Classes Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary.
Static. Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. A static method does not operate on an object double dY.
Packages. Package 1.Avoid naming conflicts. Put classes into packages so that they can be referenced through package names. 2.Distribute software conveniently.
CS 61B Data Structures and Programming Methodology July 3, 2008 David Sun.
1 JAVA API & Packages Starring: Java Documentation Co-Starring: BlueJ IDE.
Class Libraries Chapter 1 1 Source Intro to Java Programming Y. Daniel Liang.
Inheritance A Review of Objects, Classes, and Subclasses.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
Even More Java. Java Packages What is a package? Definition: A package is a grouping of related types providing access protection and name space management.
Introduction to Android
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. A class represents a single concept from the problem domain, or a.
CSS446 Spring 2014 Nan Wang.  A Java program consists of a collection of classes.  Package is a set of related classes. 2.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
1 Features of Java (2) CS 3331 Sections 4.5 and 4.6.
JAVA INTRODUCTION. What is Java? 1. Java is a Pure Object – Oriented language 2. Java is developing by existing languages like C and C++. How Java Differs.
1 Chapter 6 Programming with Objects and Classes F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive.
Packages. The main feature of OOP is its ability to support the reuse of code: –Extending the classes –Extending interfaces The features in basic form.
1 Wrapper Classes  Sometimes we want to use a primitive type as an object, so there are wrapper classes that will help us.  In particular, we need to.
CSI 3125, Preliminaries, page 1 Packages. CSI 3125, Preliminaries, page 2 Packages Packages are containers for classes Collection of classes Packages.
Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Chapter 3: Using Classes and Objects Coming up: Creating Objects.
Methods. Introducing Methods A method is a collection of statements that are grouped together to perform an operation.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
Computer Science 209 Software Development Packages.
© 2004 Pearson Addison-Wesley. All rights reserved September 5, 2007 Packages & Random and Math Classes ComS 207: Programming I (in Java) Iowa State University,
© 2004 Pearson Addison-Wesley. All rights reserved3-1 Objects Declaration: String title;  title (object variable) of type String( Class )  title is just.
1 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used as a type to declare an object reference.
Java Packages - allow you to group classes as a collection Standard Java library has packages: java.lang and java.util … Also hierarchical: java and javax.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Programming With Java ICS201 University Of Ha’il1 ICS 201 Introduction to Computer Science Inheritance.
JAVA MULTIPLE CHOICE QUESTION.
3 Introduction to Classes and Objects.
Android Runtime – Dalvik VM
Software Development Packages
Classes, Libraries & Packages
Packages Written part of final exam Alex Rudniy
Packages and Interfaces
Packages, a method of subdividing a Java program and grouping classes
Packages From Deitel & Deitel.
Java External Libraries & Case Study
Creating Objects A variable holds either a primitive value or a reference to an object A class name can be used as a type to declare an object reference.
Applying OO Concepts Using Java
PACKAGES.
Interfaces,Packages and Threads
Presentation transcript:

Joel Adams and Jeremy Frens Calvin College Packages Joel Adams and Jeremy Frens Calvin College

Organization of Classes A class encapsulates the data and behavior of an object. Related classes are grouped together in a package. Organization! java.lang for basic Java-language classes (e.g., String, Thread, etc.) java.util for utility classes (e.g., List, Map, StringTokenizer, etc.) java.net for networking classes (e.g., Socket, URL, etc.) javax.swing for the Swing GUI library Etc…

Create Your Own Creating a package is implicit: package com.siemens.foobar; public class Person { … } Must be first statement in file. Creates (or adds to) a package named com.siemens.foobar. Creates a new class with the fully qualified name com.siemens.foobar.Person.

Conventions Use lowercase letters (convention). Separate words (valid Java identifiers) with periods (required). Package name begins with domain name in reverse order (e.g., edu.siemens, com.siemens, edu.calvin, etc.) Rest of package name is your choice.

Importing You should import classes you use directly. Wildcard import: import com.siemens.foobar.*; Targeted import: import com.siemens.foobar.Person; Must come after package declaration and before class definitions. You can skip an import and always use a fully qualified name.

Packages and Directories Package name has impact on directory structure: package com.siemens.foobar; byte-code files project build com siemens foobar source files src com siemens foobar The build and src directories can be the same. A good IDE (e.g., Eclipse, JBuilder) will manage the directories.

Visibility Packages add a new wrinkle to the visibilities: public visibility: accessible anywhere. private visibility: accessible only by the same class. protected visibility: accessible by the same class, by its subclasses, by any other class in the same package. default visibility: accessible within the package.