Java programming course: 13.1 Graphical user interfaces

The previous lesson discussed thread waiting and notification. Previous lesson: 12.4 Thread waiting and notificationCourse contents  Graphical user interfaces A Graphical User Interface provides the primary means by which users of your application interact with it. In this section you will learn: The structure of graphical programsSome common ...

Java programming course: 12.4 Thread waiting and notification

In the previous lesson you saw how to implement the Runnable interface. Previous lesson: 12.3 Implementing the Runnable interfaceCourse contents  Thread waiting and notification For some types of multithreaded application, using the synchronized keyword alone is not enough on its own. Imagine that at the zoo the penguins are fed fish from a ba...

Java programming course: 12.3 Implementing the Runnable interface

In the previous lesson we showed how to extend the Thread class. Previous lesson: 12.2 Extending the Thread classCourse contents Implementing the Runnable interface You have seen that you can extend the Thread class to define a class which can run concurrently with other threads, but what if the class you want to make multithreaded already extends ...

Java programming course: 12.2 Extending the Thread class

In the previous lesson we learnt about the concepts of multithreading. Previous lesson: 12.2 MultithreadingCourse contents Extending the Thread class The first way of defining a multithreaded class is to extend the Thread class and override its run() method. Here is the Booker class which does just that: package virtualzoo.core;public class Booker ...

Java programming course: 12.1 Multithreading

In the previous lesson we saw how to use Map. Previous lesson: 11.4 using MapCourse contents  Multithreading Threads allow your application to perform more than one process concurrently. In this section you will learn: The principles of multi-threadingExtending the Thread classImplementing the Runnable interfaceUsing wait() and notifyAll() to ...

Java programming course: 11.4 Using a Map for zookeeper's responsibilities

In the previous lesson we looked an maps. Previous lesson: 11.3 MapsCourse contents  Using a Map for zookeeper's responsibilities At the zoo, each zookeeper is responsible for certain pens, as listed below: Alice looks after the monkeys and penguinsBob looks after the lions, monkeys and penguinsCharles only looks after the penguins This can be...

Java programming course: 11.3 Maps

In the previous lesson we used our Pen class in ZooAdministrator. Previous lesson: 11.2 Using Pen in ZooAdministratorCourse contents  Maps  You can think of a Map as being like a dictionary – you can look up a word to find its definition. But maps in Java are much more flexible than that since you can use them to look up any object to fin...

Java programming course: 11.2 Using the Pen class in ZooAdministrator

 In the previous lesson we looked at lists and set. Previous lesson: 11.1 Lists and SetsCourse contents Using the Pen class in ZooAdministrator The zoo administrator will keep a record of each pen in the zoo, being one for each of the animal types. In the ZooAdministrator class define these Pen instance variables: private Pen lionPen, monkeyPe...

Java programming course: 11.1 Collections and maps

 In the previous lesson you learnt how to debug a class. Previous lesson: 10.3 How to debug a classCourse Contents Collections and maps The Java Collections Framework provides a set of classes and interfaces that let you manage groups of related objects in a more powerful way than arrays. In this section you will learn: How the collections fra...

Java programming course: 10.3 How to debug a class

In the previous lesson you saw how to test a class. Previous lesson: 10.2 How to test a class using JUnitCourse contents How to debug a class Finding where you have a bug in your classes can sometimes be a time-consuming process. To help you, NetBeans incorporates a debugging tool that lets you set one or more breakpoints at any point in your code....

Java programming course: 10.2 How to test a class using JUnit

In the previous lesson we saw how to document your classes using the Javadoc tool. Previous lesson: 10.1 How to document your classesCourse contents How to test a class using JUnit Testing that your classes do what they are supposed to is an essential part of software development. In practical terms, it is impossible to ensure that software is tota...

Java programming course: 9.3 Recommended overrides from the Object class

In the previous lesson we looked at preventing the compromisation of immutable classes. Previous lesson: 9.2 Preventing the compromisation of immutable classesCourse contents Recommended overrides from the Object class You will recall that every class (both those supplied by Java and those you write yourself) inherits from the Java supplied class c...

Java programming course: 9.1 Immutable classes and the Object class

In the previous lesson we built the Person utility class. Previous lesson: 8.3 Person utility classCourse contents  Immutable classes and the Object class  Immutable classes are those which don't enable their state to change after they have been constructed. The Object class provides a core set of functionalities inherited by every Java c...

Java programming course: 8.3 Person utility class

In the previous lesson we discussed what utility classes are. Previous lesson: 8.2 Utility classCourse contents  Person utility class Now that you have a separate Utilities project containing the Gender enum, you can create the class called Person in the com.example.util package of Utilities: package com.example.util;public class Person { // I...

Java programming course: 8.2 Utility classes

In the previous lesson we looked at refactoring. Previous lesson: 8.1 RefactoringCourse contents Utility classes When developing any application, it makes sense to reuse classes which have already been developed, assuming you can find something suitable, of course. This will save you the time of having to specify, code and test something from scrat...

Java programming course: 8.1 Refactoring and utility classes

In the previous lesson we created our own Exception class. Previous lesson: 7.3 Creating an Exception classCourse contents Refactoring and utility classes Refactoring refers to the process of improving how you application is internally structured. Utility classes can be defined to provide commonly used services for multiple applications. In this se...

Java programming course: 7.3 Creating your own exception class

In the previous lesson we saw how to throw exceptions. Previous lesson: 7.2 Throwing exceptionsCourse contents Creating your own exception class It is possible to create an exception class of your own, if you can't find an appropriate Java supplied one to use. As an example, in a later section you will develop a user interface where the user can ma...

Java programming course: 7.2 Throwing exceptions

 In the previous lesson we introduced exceptions. Previous lesson: 7.1 ExceptionsCourse contents Throwing exceptions  Instead of catching an exception and handling it in the current method, you could choose to throw it back to the client object. You would do this if different clients might need to handle the situation in different ways. I...

Java programming course: 7.1 Exceptions

In the previous lesson we looked at sorting in alternative sequences. Previous lesson: 6.5 Sorting in alternative sequencesCourse contents Exceptions  Exceptions are Java's way of controlling unexpected occurrences, and which allows you can gain control over what to do in these circumstances. In this section you will learn: What exceptions are...

Java programming course: 6.5 Sorting in alternative sequences

In the previous lesson you saw how to sort arrays and objects in their "natural" sequence. Previous lesson: 6.4 Sorting arraysCourse contents  Sorting in alternative sequences You have seen that making your class implement the Comparable interface and implementing its compareTo() method lets you define a class's natural (or default) ordering. ...