Tutorial Eclipse Java Beginner
Tutorial Eclipse Java Beginner
Table of Contents
Introduction.........................................................................................................................................2
Tutorial Target Audience.....................................................................................................................2
Tutorial Objectives..............................................................................................................................2
Why learn Java with Eclipse?.............................................................................................................3
Topics Covered...................................................................................................................................3
Tutorial Approach................................................................................................................................3
Getting The Most From This Tutorial..................................................................................................3
Sample Java Application – Personal Lending Library........................................................................4
Downloading and Installing Eclipse ...................................................................................................4
Playing the Lessons............................................................................................................................5
Re-Sizing the Video........................................................................................................................5
Closed Captions and Lesson Table of Contents............................................................................5
Lesson Outlines..................................................................................................................................6
Lesson 1 – Create Your First Java Class.......................................................................................6
Lesson 2 – Add Methods To Class.................................................................................................6
Lesson 3 – Use Eclipse Scrapbook................................................................................................6
Lesson 4 – JUnit Testing in Eclipse, Part 1....................................................................................6
Lesson 5 – JUnit Testing Continued...............................................................................................7
Lesson 6 – Using Test-First Development in Eclipse.....................................................................7
Lesson 7 – Create Book Class.......................................................................................................7
Lesson 8 – Add Person to Book Class...........................................................................................7
Lesson 9 – MyLibrary Class and ArrayList.....................................................................................7
Lesson 10 – Start on MyLibrary Class...........................................................................................7
Lesson 11 – Create first methods in MyLibrary class.....................................................................8
Lesson 12 – Create checkOut, checkIn Methods..........................................................................8
Lesson 13 – Continue checkOut Method.......................................................................................8
Lesson 14 – Finish checkOut Method............................................................................................8
Lesson 15 – Finish MyLibrary Methods..........................................................................................8
Lesson 16 – Create main Method and JAR File.............................................................................9
Alphabetical Index by Lesson.............................................................................................................9
Glossary of Terms.............................................................................................................................12
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 1 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Additional Resources........................................................................................................................14
Eclipse Websites..........................................................................................................................15
Java Websites...............................................................................................................................15
Java Books...................................................................................................................................15
Code Snapshots...............................................................................................................................15
Lesson 1 – Person class (fields and constructor)........................................................................15
Lesson 2 – Person class (with get and set methods)...................................................................16
Lesson 3 (scrapbook snapshots)..................................................................................................17
Lesson 5 – PersonTest class........................................................................................................17
Lesson 6 – Added toString() Method to Person class..................................................................18
Lesson 7 – TestBook and Book Classes......................................................................................20
Lesson 8 – Add Person to Book Class.........................................................................................21
Lesson 9 – MyLibrary Class and ArrayList...................................................................................23
Lesson 10 – Start on MyLibrary Class.........................................................................................23
Lesson 11 – Create first methods in MyLibrary class...................................................................24
Lesson 12 – Create checkOut, checkIn Methods........................................................................27
Lesson 13 – Continue checkOut Method.....................................................................................31
Lesson 14 – Finish checkOut Method..........................................................................................33
Lesson 15 – Finish MyLibrary Methods........................................................................................35
Lesson 16 – Create main Method and JAR File..........................................................................41
Introduction
This document is designed to accompany the “Eclipse And Java For Total Beginners” video tutorial,
which is available at http://eclipsetutorial.sourceforge.net/.
Tutorial Objectives
The objectives of this tutorial are as follows:
Demonstrate the basics of using Eclipse for writing Java programs
Demonstrate how to use Eclipse for agile software development
Demonstrate how to use existing Java learning resources (tutorials, examples, books) within
Eclipse
Create a foundation for continuing to learn Java and Eclipse
Note that Java and Eclipse are both large subject areas that cannot possibly be mastered in a short
period of time. This tutorial will help get you started and give you some of the skills needed to learn
on your own.
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 2 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Topics Covered
This tutorial will cover the following topics:
Basics of Eclipse for Java development
Basics of Java and object-oriented programming (OOP)
Test-driven development (TDD) and unit testing in Eclipse
Tutorial Approach
The tutorial is organized around the following activities.
Write a small sample Java application to track your personal lending library.
Use the “test-first” approach to develop most methods.
Write a “test drive” program and create an executable JAR file, and run the JAR file from the
system console.
Concepts are introduced as needed during the development of the sample applications.
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 3 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 4 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
copy the zip file to your root directory (e.g., “C:\”) and then unzip the downloaded zip file. This will
create a folder called “C:\eclipse”. The Eclipse programs will be created in several subfolders
(configuration, features, plugins, readme). The procedure for Linux is similar, except your unzip the
.tar.gz file.
The audio track of each lesson can be accompanied by closed captions (subtitles), which display in
the lower portion of the video. Press the “CC” button in the lower right corner to toggle them on and
off. Each lesson also contains a table of contents that allows you to jump to a specified point inside
the video. To access the table of contents, click on the Table of Contents icon in the lower right corner
of the video. Next to the Table of Contents control is the Volume control. The controls are shown
above.
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 5 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Lesson Outlines
Lesson 1 – Create Your First Java Class
Create Java project in Eclipse
Create Java package
Discuss the Lending Library Application
Introduce classes and objects, naming conventions
Write a simple Java class (Person)
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 6 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Field Hiding
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 7 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 8 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
addPerson() method..................................................................................................................11
agile software development........................................................................................................4
ArrayList<> class.........................................................................................................................9
assertEquals() method ...............................................................................................................5
assertTrue() method..................................................................................................................10
Book class...................................................................................................................................7
boolean type..............................................................................................................................10
build path.....................................................................................................................................4
capitalization in Java...................................................................................................................1
checkOut() method....................................................................................................................12
class (Java).................................................................................................................................1
code assist (CTRL+Space).........................................................................................................2
code assist template...................................................................................................................2
comments: in-line (//)...................................................................................................................1
constructor (Java).......................................................................................................................1
Convert Local Variable to Field, Eclipse Wizard.......................................................................11
CTRL+/, toggle in-line comments................................................................................................8
CTRL+Shift+P – find matching curly brace...............................................................................13
CTRL+Space – code assist........................................................................................................2
curly brace, highlighting in Eclipse............................................................................................13
Eclipse code assist (CTRL+Space)............................................................................................2
Eclipse Explorer class view.........................................................................................................2
Eclipse scrapbook.......................................................................................................................3
Eclipse user interface..................................................................................................................2
equals method for Strings (vs. == operator).............................................................................14
executable JAR file...................................................................................................................16
execute button, Eclipse scrapbook.............................................................................................3
Export to Java Archive (JAR) file, Eclipse wizard.....................................................................16
expressions.................................................................................................................................3
extends keyword.........................................................................................................................4
extreme programming.................................................................................................................4
fields (class)................................................................................................................................1
for each loop..............................................................................................................................14
Generate Getters and Setters Wizard.........................................................................................2
Generics feature, Java..........................................................................................................9, 10
get() method, ArrayList................................................................................................................9
getAvailableBooks() method ....................................................................................................15
getBooksForPerson() method...................................................................................................14
getter methods............................................................................................................................2
getUnavailableBooks() method.................................................................................................15
if then statement .......................................................................................................................12
indexOf() method, ArrayList........................................................................................................9
inspect button, Eclipse scrapbook..............................................................................................3
instanceof operator...................................................................................................................10
JAR archive file.........................................................................................................................16
java -jar command.....................................................................................................................16
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 9 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 10 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 11 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Glossary of Terms
Access Modifier Reserved words “public”, “private”, “protected” in Java. Control whether
classes and members may be accessed from any class, only this class,
subclasses. Default is access from any class in the package.
Agile (or Extreme) Methodology for developing software that emphasizes, among other
Development things, unit testing as part of development process.
API (Application The way one program uses another program. In Java, the API can be
Programming Interface) thought of as the collection of public methods for a class or package.
Class Main building block in Java. Contains members, including fields and
methods. Classes are the “blueprint” for creating objects.
Constructor Special block of code used to create an instance of a class (or, if you
prefer, an object whose type is the class). Used with the “new” keyword
(e.g., Person p = new Person() calls the Person() constructor).
Field Member in a class that holds data (e.g., name, age, etc.). Usually marked
private so that other programs cannot directly access.
IDE (Integrated Program, like Eclipse, that provides the different tools required to develop
Development a software package.
Environment)
JVM (Java Virtual The program that runs Java programs on a specific platform. Java source
Machine) (also known as code is compiled into .class files. These contain the instructions used by
Java Runtime Engine or the JVM to actually run the programs on a Windows PC, a Linux computer,
JRE) a Mac computer, etc. The JVM is written for each platform supported by
Java.
JUnit Test A Java class used to test individual methods in a class. Used to build test
cases, e.g., when using agile development methodology.
Method Member in a class that does some processing (e.g., like a subroutine or
function in other languages).
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 12 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Method Argument, Method Parameters refers to the list of variables in a method declaration.
Parameter Arguments are the actual values that are passed in when the method is
invoked. When you invoke a method, the arguments used must match the
declaration's parameters in type and order. For example, in the method
“name” is the parameter for this method. If this method is used as follows:
myObject.setName(“Fred”);
“Fred” is the argument of the method and it must match the type of the
method’s parameter.
Method Signature A method’s name plus it’s parameter list. For example, a method defined
as “setName (String name)” has a method signature of “setName(String)”.
Method signatures are important because they allow methods to be
overloaded (i.e., have the same name but different signatures). For
example, the method “setName(String firstName, String lastName) could
be an overload of “setName(String name)” because it as a different
signature (“setName(String, String)”).
Overload (Method) To provide multiple methods with the same name but different parameters
(i.e., same name but different signatures).
Override (Method) When a subclass implements a method inherited from the super class, this
method is said to be overridden.
Package Packages are imported into a source file to save typing the full name of
the class (e.g., can say “Person” instead of
“org.eclipsetraining.librarytutorial.Person” and to avoid the possibility of
two classes having identical names.
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 13 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Refactor To improve a program without changing the way it works (i.e., its API).
Example include renaming fields or variables, streamlining code, etc. Very
important in agile development because of emphasis on self-documenting
code.
Reference Variable In Java, variable that holds an object reference (e.g., p = new Person();).
Points to an area on the “heap” where the object resides. Contrast with
value variable.
Scrapbook Page Area in Eclipse where you can execute Java code “snippets” and see how
they work. Great for experimenting with Java statements.
Static Method A method that belongs to the entire class instead of one instance of the
class. Invoked with <Class>.<Method> (e.g., Person.getTotalCount()).
Used for methods that don’t rely on any one instance of a class.
Swing A set of standard Java packages that implement a graphical user interface
without using any “native” code.
SWT (Standard Widget Set of Java classes and native programs developed by Eclipse to allow
Toolkit) Java programs to have the look and feel of native programs on each
platform. Used to create the Eclipse IDE.
Value Variable In Java, variable that holds the value of a Java primitive (e.g., integer,
character, etc.). Held in the memory stack. Contrast with reference
variable.
Workspace Top-level container for Eclipse work. Holds multiple projects. In a single
Eclipse session, only one workspace can be active.
Additional Resources
There are many resources available for learning more about Eclipse and Java. These are just a few
that I’ve found helpful.
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 14 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Eclipse Websites
www.eclipse.org/resources. This lists a number of articles, books, presentations,
demonstrations and other resources on a variety of topics related to Eclipse.
eclipse.newcomer newsgroup. This is a friendly, active newsgroup where newcomers to
Eclipse can ask questions. The search feature of this and other newsgroups can be especially
valuable, since there is a good chance that your question has already been asked and
answered.
Beginning Eclipse Tutorial on ArcTech Software LLC website. Written tutorial to get you started
with Eclipse and Java. Login required to download. It has a very good section on downloading
and installing the Java JDK. Link to tutorial is
https://www.arctechsoftware.com/tutorial/tutorial.do?subcatId=1. Link to home page is
https://www.arctechsoftware.com/tutorial/welcomePage.do.
Java Websites
The Java Tutorials from Sun (http://java.sun.com/docs/books/tutorial/java/index.html). The gold
standard for learning Java, and it’s free.
JavaRanch Big Moose Saloon web site (http://saloon.javaranch.com/cgi-
bin/ubb/ultimatebb.cgi?category=1). This has a variety of forums, including Java in General
(beginner), Java in General (intermediate), and many other Java topics. Very active and
friendly, with knowledgeable moderators.
The Java Developers Almanac 1.4 (http://www.exampledepot.com/). Contains Java code
samples for many topics.
Java Books
Head First Java, by Kathy Sierra & Bert Bates. Excellent, fun, creative book for Java and OOP
beginners.
Thinking In Java, by Bruce Eckel. Excellent, thorough reference for Java. For all levels of
programmer.
Effective Java, by Joshua Bloch. Concise book documents specific recommendations for Java
best practices. For intermediate to advanced programmers.
Code Snapshots
The following pages contain code snapshots as of the end of each lesson. These can be used to
compare your code to or to help you fix any problems you might have. If needed, you can copy and
past this code into your Eclipse Java source files. Also, if you want to start the tutorial in the middle,
these can help you catch up to the correct point.
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 15 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
// constructors
public Person() {
name = "unknown name";
maximumBooks = 3;
}
}
package org.totalbeginner.tutorial;
// constructors
public Person() {
name = "unknown name";
maximumBooks = 3;
}
//methods
public String getName() {
return name;
}
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 16 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
return maximumBooks;
}
Expressions:
2 + 2
int a = 5;
a = a * 10;
a
package org.totalbeginner.tutorial;
import junit.framework.TestCase;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 17 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
assertEquals(3, p1.getMaximumBooks());
}
package org.totalbeginner.tutorial;
// constructors
public Person() {
name = "unknown name";
maximumBooks = 3;
}
//methods
public String getName() {
return name;
}
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 18 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
import junit.framework.TestCase;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 19 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
p4.setMaximumBooks(7);
String testString = "Fred Flintstone (7 books)";
assertEquals(testString, p4.toString());
}
package org.totalbeginner.tutorial;
import junit.framework.TestCase;
package org.totalbeginner.tutorial;
String title;
String author;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 20 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
import junit.framework.Test;
import junit.framework.TestSuite;
package org.totalbeginner.tutorial;
String title;
String author;
Person person;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 21 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
import junit.framework.TestCase;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 22 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
list.remove(b1);
list
package org.totalbeginner.tutorial;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 23 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
import java.util.ArrayList;
import junit.framework.TestCase;
// test constructor
public void testMyLibrary() {
MyLibrary ml = new MyLibrary("Test");
assertEquals("Test", ml.name);
package org.totalbeginner.tutorial;
import java.util.ArrayList;
String name;
ArrayList<Book> books;
ArrayList<Person> people;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 24 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
import java.util.ArrayList;
import junit.framework.TestCase;
// test constructor
public void testMyLibrary() {
MyLibrary ml = new MyLibrary("Test");
assertEquals("Test", ml.name);
ml = new MyLibrary("Test");
ml.addBook(b1);
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 25 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
ml.addBook(b2);
assertEquals(2, ml.getBooks().size());
assertEquals(0, ml.getBooks().indexOf(b1));
assertEquals(1, ml.getBooks().indexOf(b2));
ml.removeBook(b1);
assertEquals(1, ml.getBooks().size());
assertEquals(0, ml.getBooks().indexOf(b2));
ml.removeBook(b2);
assertEquals(0, ml.getBooks().size());
}
}
package org.totalbeginner.tutorial;
import java.util.ArrayList;
String name;
ArrayList<Book> books;
ArrayList<Person> people;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 26 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
import java.util.ArrayList;
import junit.framework.TestCase;
// test constructor
public void testMyLibrary() {
MyLibrary ml = new MyLibrary("Test");
assertEquals("Test", ml.name);
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 27 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
ml = new MyLibrary("Test");
ml.addBook(b1);
ml.addBook(b2);
assertEquals(2, ml.getBooks().size());
assertEquals(0, ml.getBooks().indexOf(b1));
assertEquals(1, ml.getBooks().indexOf(b2));
ml.removeBook(b1);
assertEquals(1, ml.getBooks().size());
assertEquals(0, ml.getBooks().indexOf(b2));
ml.removeBook(b2);
assertEquals(0, ml.getBooks().size());
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 28 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
ml.addPerson(p2);
}
assertEquals("Fred", b1.getPerson().getName());
package org.totalbeginner.tutorial;
import java.util.ArrayList;
String name;
ArrayList<Book> books;
ArrayList<Person> people;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 29 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 30 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
b1.setPerson(null);
return true;
}
else {
return false;
}
}
package org.totalbeginner.tutorial;
import java.util.ArrayList;
String name;
ArrayList<Book> books;
ArrayList<Person> people;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 31 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 32 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
import java.util.ArrayList;
String name;
ArrayList<Book> books;
ArrayList<Person> people;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 33 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
{
result.add(aBook);
}
}
return result;
}
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 34 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
package org.totalbeginner.tutorial;
import java.util.ArrayList;
import junit.framework.TestCase;
// test constructor
public void testMyLibrary() {
MyLibrary ml = new MyLibrary("Test");
assertEquals("Test", ml.name);
ml = new MyLibrary("Test");
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 35 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
assertEquals(0, ml.getBooks().size());
ml.addBook(b1);
ml.addBook(b2);
assertEquals(2, ml.getBooks().size());
assertEquals(0, ml.getBooks().indexOf(b1));
assertEquals(1, ml.getBooks().indexOf(b2));
ml.removeBook(b1);
assertEquals(1, ml.getBooks().size());
assertEquals(0, ml.getBooks().indexOf(b2));
ml.removeBook(b2);
assertEquals(0, ml.getBooks().size());
addItems();
assertEquals("Fred", b1.getPerson().getName());
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 36 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
ml.checkOut(b1, p1);
ml.checkOut(b2, p1);
testBooks = ml.getBooksForPerson(p1);
assertEquals(2, testBooks.size());
assertEquals(1, testBooks.indexOf(b2));
ml.checkOut(b1, p1);
testBooks = ml.getAvailableBooks();
assertEquals(1, testBooks.size());
assertEquals(0, testBooks.indexOf(b2));
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 37 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
ml.checkOut(b2, p1);
testBooks = ml.getAvailableBooks();
assertEquals(0, testBooks.size());
ml.checkOut(b1, p1);
ml.checkOut(b2, p2);
testBooks = ml.getUnavailableBooks();
assertEquals(2, testBooks.size());
assertEquals(1, testBooks.indexOf(b2));
package org.totalbeginner.tutorial;
import java.util.ArrayList;
String name;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 38 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
ArrayList<Book> books;
ArrayList<Person> people;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 39 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
}
else {
return false;
}
}
{
result.add(aBook);
}
}
return result;
}
}
return result;
}
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 40 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
result.add(aBook);
}
}
return result;
}
package org.totalbeginner.tutorial;
import java.util.ArrayList;
String name;
ArrayList<Book> books;
ArrayList<Person> people;
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 41 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 42 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
{
result.add(aBook);
}
}
return result;
}
}
return result;
}
}
return result;
}
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 43 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
testLibrary.addBook(b1);
testLibrary.addBook(b2);
testLibrary.addPerson(jim);
testLibrary.addPerson(sue);
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 44 of 45
Eclipse and Java for Total Beginners
Tutorial Companion Document
}
}
Copyright © 2007 Mark Dexter. Licensed under the Educational Community License version 1.0. Page 45 of 45