Showing posts with label lecture. Show all posts
Showing posts with label lecture. Show all posts

Friday, April 6, 2012

Iterators and Generics

Chapter 12 also talks about the Iterator interface. Iterators are a bit clumsier than using the 'foreach' (for (Type item: Collection) form), but they have the advantage that you can remove elements from the collection while iterating over it. The video below shows you how to use them:



The video below is a longer example showing how one might implement the Iterator interface in a class.




Finally, the next one shows you how to build your own generic class.



Tuesday, April 3, 2012

Swing Applications

On Wednesdays' lecture we will be talking about the Java Swing library (Chapter 13 from the textbook, which you can download from the textbook website. This material will not be on the tests, but it will be on the next Lab. The video below also shows you how to build a simple Swing app.

In class I also demoed the windowbuilder plugin for eclipse, which lets you drag-and-drop your way to a working GUI. But, if you are planning on doing a lot of GUI drawing, you will want to use netbeans. It is much more stable.




Friday, March 30, 2012

ArrayLists and HashSets

Next week we will be covering Chapter 12, which talks about some of the built-in collection classes in Java, such as ArrayList and HashSet and HashMap:





Thursday, March 22, 2012

Recursion

On Monday's lecture we will discuss Recursion: Chapter 11 of the textbook.



Binary Search implementation using Recursion

Serializable Interface

You can easily write any Java object to a file, as long as it implements the Serializable interface. The following video shows you how:


Friday, March 16, 2012

Reading and Writing Files

On Wednesday's lecture we will cover the reading and writing of files (Chapter 10).

Reading a CSV file


Writing to a text file


Binary files


Wednesday, March 14, 2012

Exceptions

On Monday's lecture we will discuss Exceptions, which is Chapter 9 of the textbook. Here are a couple of videos on the topic.

Exceptions



Creating your Own Exceptions


Monday, February 27, 2012

Interfaces and Abstract Classes

The last two topic from Chapter 8, which is the last Chapter we will cover before Test 2, are Interfaces and Abstract classes. We will cover these on lecture Monday and the rest of the lectures until the test we will be doing practice exercises.








Also, I just found this set of Java tutorials which are very nicely done, and cover a lot of the same material we are covering.

Friday, February 24, 2012

More Array Examples

Below is an example of a more complicated program using arrays; I write a short program to print out a row from Pascal's triangle. As I mention in the video, this video was inspired by a blog post on good interview questions for developers. Some employers feel that asking candidates to write this program on a whiteboard is a good way to filter out those who can code from those who cannot. I can say that this would be a great question for the final in this class (well, not anymore).


Wednesday, February 22, 2012

Inheritance and Polymorphism

In today's lecture we started talking about inheritance and polymorphism. These are covered in Chapter 8 of the textbook and below.

Inheritance





Polymorphism


Friday, February 17, 2012

More Fun with Arrays:2D, Sorting, Tic-Tac-Toe

Next week we will do a lot of array examples. First, we have multi-dimensional arrays:





Here is an example of how to implement the insertion sort algorithm.





Finally, an example of how to build a tic-tac-toe board using arrays.


Wrapper Classes and Arrays

Next week we will be going over wrapper classes





and getting deep into Arrays





Here is an example of using an Array within a class.





Thursday, February 16, 2012

Building an Immutable Class, Unit testing, Packages

In lecture yesterday I covered the building of an immutable class, using the final keyword. The video below recapitulates what we learned.


Immutable Distance Class





The video below talks about Java packages and how to create them in eclipse.


Packages


Sunday, February 12, 2012

Static Properties and Methods

Chapter 6 covers static member variables and methods. The video below summarizes these concepts.


Friday, February 10, 2012

Equals and Constructors

Next week we will also cover what it means for two object to be "equal". Chapter 6 will then introduce us to constructors.


Are those two objects equal?



Constructors



Thursday, February 9, 2012

Classes, Object, and Methods

Next week we will continue delving deeper into Java classes, objects, and methods. Watch the following videos.


Methods calling Methods



Call by reference, call by value (or, what can go wrong when you pass an object as an argument to a method)



Java Strings are immutable



Monday, February 6, 2012

Java Classes, Properties and Methods

On Thursday's class we will introduce Java Classes. You should have read Chapter 5 and watched the videos below by then.


Java Classes in Eclipse


Java Getters and Setters

Tuesday, January 31, 2012

Loops Example: Wheel of Fortune

In the following video I show a more complicated example of using a loop. I write a program that simulates flipping the letters as done by Vanna White in Wheel of Fortune (that is, as done in the game of Hangman).

loops example: wheel of fortune


Nested For Loops Example

Nested for-loops are very very useful.


Sunday, January 29, 2012

Loops Example: Adding Numbers

Below I show how to write a loop that adds up some numbers the user gives us. This is a very frequently used pattern.



adding numbers with a loop