Threads Database Profiling Regular expressions Random numbers Compression Exceptions C Equivalents in Java

Using Threads in Java

An introduction to "raw" threads in Java, looking at the Thread and Runnable classes and issues such as thread interruption and thread safety. Plus more advanced threading information such as:

Synchronization and concurrency in Java

Going "beyond the thread", with various aspects of synchronization in Java:

The following go in to some more detail on the Java 5 synchronization libraries:

  • The Atomic classes in Java 5 provide a more lightweight way of atomically accessing various types of variables.
  • Explicit locks in Java 5 explains a more flexible locking mechanism that in some cases may be a benefit over the standard synchronized block.
  • The wait/notify mechanism (and Java 5 alternatives) looks in detail at the standard wait/notify, which pre-Java 5 was the main means for threads to communicate with one another, and at constructions in Java 5, such as queues and Semaphores, which now make it less necessary. In particular, the Java BlockingQueue implementations are useful for implementing the typical producer-consumer pattern.
  • A page on ConcurrentHashMap Performance compares the concurrency of the latter class with the pre-Java 5 method of synchronizing around an ordinary HashMap.
Introduction and discussion of exceptions, Java's means of managing errors and unexpected conditions. Topics include a general introduction to exceptions, exception-handling syntax including the try/catch block and a look at the exception hierarchy. More advanced topics include uncaught exception handlers and exception recasting.
Java Servlets
Servlets are an excellent low-resource way of serving dynamic web pages, and are increasingly supported by cheap hosting packages. In our introduction, we look at how to write a Servlet, then look at more advanced techniques such as using sessions and cookies and reading request headers.
What is the Java equivalent of...?
New section on how to immitate in Java certain features of other languages such as C++, starting with the Java equivalent of const plus the Java equivalents of C/C++ memory management operators such as new, delete and malloc().
Doing math in Java

This section gives an overview of using floating point primitives in Java. The section includes a look at the performance of java.util.Math methods. We also look at the BigDecimal and BigInteger classes, which allow calculations on numbers of arbitrary numbers of digits, and include some information on the performance of multiplication using both a naive method and implementations of Karatsuba's algorithm.

Java Collections

This tutorial looks at using collections in Java firstly from a practical point of view, focussing on the basic list (including how to sort data in a list), set and map. Advanced topics then include guidelines to writing a hashCode() method and a look at how the String hash function works, and a look at the performance of the Java sort algorithm.

Finally, we look at some advanced hashing techniques to reduce memory usage in certain cases.

Java & random numbers
Are you generating and using random numbers correctly in your Java programs? Are you aware of the security and testing issues of not using them correctly? Find out more with this Java random number tutorial.
Java memory usage
Articles on how to calculate or query the use of Java objects, including the Classmexer agent which provides calls to make it easier to query the memory usage of Java objects from the JVM itself via the Java Instrumentation framework.
How to fix...
Find out what to do with those awkward OutOfMemoryErrors, StackOverflowErrors and StreamCorruptedExceptions.
Java Swing
How to use Swing, Java's rich and extensible user interface library. Currently available tutorial pages include a Swing components gallery, giving an overview of the most common UI components.
Java cryptography
An overview of the main encryption and authentication facilities offered by Java, with a discussion of caveats you need to be aware of to use them securely.
Databases with Java

How to access a database from Java. Topics covered include connecting to a database with Java and the mapping between SQL and Java data types.

Profiling in Java 5

This section looks at various aspects of profiling, focussing on how it actually works, and how with Java 5 you can write some flexible profiling code of your own, and even leave profiling running permanently on your live server.

Regular Expressions in Java

Tutorial on using regular expressions from scratch, including basic expressions with the String.matches() method, moving on to topics such as the Pattern and Matcher classes, used to give more control over expression matching, and capturing groups and the performance of string tokenisation using regular expressions. Plus examples of using regexular expressions for IP location and HTML scraping.

Java I/O

This section gives a basic tutorial on I/O in Java, concentrating corrently on the standard I/O libraries.

Bits and bytes in Java

A look at how computers store and manipulate numbers, with particular reference to Java, including a look at binary numbers in general, and how they apply to computer number representation.

Data compression in Java

A look at how to use the standard compression library, including some advanced tips for improving compression ratio in Java. We cover reading from standard ZIP and GZIP archives. Then in the how to use Deflater section, we give a 5-minute practical summary of 'raw' data compression with default options. Then we show how to configure Deflater to trade off compression ratio for CPU usage, and how in some cases we can transform our data to use the FILTERED and HUFFMAN_ONLY modes, which can give a 10-20% improvement on compression ratio with text.


 LetterMeister (word puzzle game for iPhone)
 Currency Quoter (currency converter/predictor)
 French Vocab Games for iPhone/iPad
 Vocabularium: create Spanish vocab podcasts

Also on this site

 Javamex forums: discuss/ask a Java related question!

 Querying environment variables and system properties in Java
 How to convert to/from hexadecimal in Java?
 BufferedImage tutorial: how to create images in Java
 WatchService: watching for file system modifications
 Irritating software
 Coming soon: Java localisation
 Some Java math performance measurements
 Case Study: LetterMeister
 Introduction to the Java Native Interface, allowing native (e.g. C/C++) functions to be called from Java
 Introduction to Java and XML
 How to pick a Servlet hosting company (part of the Servlet tutorial)
 Book review: Programming Collective Intelligence
 Spanish-English computing glossary
 Java for BASIC programmers: overview of the main features to look out for if you're new to Java programming but have previously programmed in some version of basic
 Java for C programmers: main features of Java from the perspective of a previous C programmer
 Java and AJAX programming
 How to time things in Java: comparison of System.currentTimeMillis() vs System.nanoTime()
 Debugging the PSP JVM

Copyright © Javamex UK 2014. All rights reserved.
Unless otherwise specified, editorial content written by Neil Coffey.
Latest update 10 February 2014.