Exercises, examples and other material relating to training module J714. This topic is presented on public courses
Learning to Program in Java,
Java Bootcamp,
Java Programming for the Web
The java.util package contains many powerful tools for computer scientists, and is an essential element of most Java applications. You'll learn when and how to use stacks, hash tables and many other utility classes. You'll learn how to sort, how to make system calls (and why you shouldn't!), and how to find out more about your environment.
Related technical and longer articles
Want something more dynamic than an array?Fundamental classes java.lang, java.util and others
289e
| Articles and tips on this subject | updated |
| 3048 | String handling - from first steps to practical examples Initial String handling examples on a training course are sometimes a bit mundane - and that's because we have to cover some of the basics like "what is a string" before we start reading them in useful quantities from files, databases, or web resources. But it's important to get those basics understood ... | 2010-11-13 |
| 2920 | Sorting - naturally, or into a different order There's a natural sort order for many things - for numbers, it's ascending, for words it's a dictionary order, for names it's by surname. But sometimes you want to sort a list of things different, or there's no provided way within a programming language to apply the natural sort to your type of thing.
In ... | 2010-08-20 |
| 2734 | for and foreach in Java Java has had a "traditional" for loop from the beginning:
for (int k=0; k<Allwords.size(); k++) {
That's three semicolon separated elements:
• initial setting
• test to see if loop should continue
• action to be taken before each re-test
So that when that's used in a loop ... | 2010-04-23 |
| 2649 | Length, size or capacity in Java? You get the length of an array, but you ask about the size() of an ArrayList, and you can inquire into the capacity() of a StringBuffer. Aren't they really all the same sort of thing? Which does Java use in which circumstance?
Java uses the word length when you're asking about something that can be ... | 2010-03-03 |
| 2323 | Java Collection Objects in the java.util package If you want to hold a number of objects in a single composite object, you call it a collection. The Java language itself (without any additional classes) supports arrays, which can hold primitives or objects (example). The java.util package adds a whole further series of classes which can be used to ... | 2009-11-02 |
| 2421 | Sorting Collections of Objects in Java The examples that I wrote / finished yesterday ended up with a program called "Zoe" in Java, which read all the records in an access log file, created an object for each of them (which, sensibly would have been called a Hit but we called a "Zoe"), and reported on that object creation.
To finish off ... | 2009-09-25 |
| 2418 | Viv.java uses unchecked or unsafe operations - explanation and cure Are you getting Java compiler messages like this?
Dorothy-2:java grahamellis$ javac Viv.java
Note: Viv.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Dorothy-2:java grahamellis$ javac -Xlint Viv.java
Which when you expand the warning with -Xlint gives:
Dorothy-2:java ... | 2009-09-24 |
| 1910 | Java - Generics If you're writing a Java program and you want to hold a whole series of objects of a similar type in a single variable, you can use and array ... except that you need to know HOW MANY of them there will be before you create the array.
Using the java.util package, there are numerous more flexible alternatives ... | 2008-11-27 |
| 42 | Do languages change? How fast do computer languages change? Not as quickly as you might expect - and yet we're regularly updating our courses. This is because the underlying bedrock (languages) don't change very much, but the functions / libraries / classes / technologies that use them do change, and the applications ... | 2008-05-10 |
| 1502 | Java, sorting, ArrayList example, generics A Java ArrayList holds an ordered sequence of items like an array, but there are differences:
1. An ArrayList has no fixed size but can be extended by adding elements later
2. An ArrayList can only hold objects (not primitives)
3. ArrayList elements are addressed by methods and not by square bracket ... | 2008-01-12 |
| 1062 | Java sorting - comparable v comparator In Java, you can sort objects that implement the Collection interface, using either the comparable interface or a comparator class. What's the difference?
A Comparable interfaced class must contain a method called compareTo to compare two objects (one being the object on which it is called and the ... | 2007-02-05 |
Examples from our training material
Background information
This module is available under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
The fundamental packages.
java.lang.
java.util.
Other fundamental packages.
Data wrappers.
Why use data wrappers?.
Other methods on Float objects.
Other methods on other data wrapper objects.
java.lang.Math.
External low-level calls.
The System class - miscellaneous features.
The System class - garbage collection.
The Runtime and Process classes.
A word of caution on system classes.
Utility objects to hold multiple simple objects.
Vectors.
Stacks.
Hashes.
Enumerations.
The StringTokenizer.
Collections.
ArrayLists.
HashSets.
Iterators and general Collection interfaces.
HashMaps.
Sorting.
Basic sorting in Java.
Comparator classes.
The Comparable interface.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Java,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.