Toggle navigation
SW
Topics
Home
Java Tutorial Index
Collections
Cryptography
Databases and JDBC
Data compression
Exceptions in Java
I/O
Maths
Memory
Profiling
Servlets
Threads
Threads & Synchronisation
Java/AJAX
Getting started with Java
Threads
BlockingQueue
BlockingQueue example: a background logger thread
ConcurrentHashMap scalability (vs synchronized hash maps)
Double-checked Locking
Double-checked Locking
Java 'final' keyword
Java 'final' keyword
Performance of Java 'final'
Performance of Java 'final'
The notifyAll() method in Java
Strings and text in Java
Synchronizing singletons using the Java class loader
Tutorial: Synchronization and concurrency in Java 5
Tutorial: Synchronization and concurrency in Java 5 (why is it difficult?)
Tutorial: Synchronization and concurrency in Java 5 (why is it difficult?: ctd)
Tutorial: Synchronization and concurrency before Java 5
Problems with the Java 1.4 synchronization model
Synchronization under the hood, and why Java 5 improves it
Synchronization under the hood, and why Java 5 improves it (ctd)
Exposure of atomic instructions in Java 5
The Atomic classes in Java
The Atomic classes in Java: atomic arrays
The Atomic classes in Java: AtomicInteger and AtomicLong
The Atomic classes in Java: AtomicReference
The Atomic classes in Java: atomic field updaters
Copy-on-write collections in Java (CopyOnWriteArrayList etc)
Atomic structures and collections in Java 5: ConcurrentHashMap
ConcurrentHashMap: usage and functionality
Iterating over a ConcurrentHashMap
Introduction to queues in Java 5
Queues in Java 5: the Queue interface
Atomic structures and collections in Java 5
Explicit locks in Java 5
Explicit locks in Java: pre-Java 5 implementation
Explicit locks in Java 5: introduction to the Lock interface
Explicit locks in Java 5: lock basics
Explicit locks in Java 5: timed and interruptible locking
Explicit locks in Java 5: read-write locks
The Java Semaphore class
The Java Semaphore class: controlling a resource pool
The synchronized keyword in Java: using a synchronized block
The synchronized keyword in Java: synchronization with main memory
Avoiding synchronization with ThreadLocal
Avoiding synchronization with ThreadLocal (example: sharing Calendar objects)
When to use ThreadLocal
The final keyword in Java
Synchronization "piggybacking" in Java
Using blocking queues in Java 5 (in preference to wait/notify)
The Java BlockingQueue (producer-consumer pattern)
Safe omission of synchronization
Synchronization methods in Java
The volatile keyword in Java
Dangers of the volatile keyword in Java
The volatile keyword in Java 5
Typical use of the volatile keyword in Java
When to use 'volatile' in Java?
Using wait(), notify() and notifyAll() in Java
Using wait() and notify() in Java
Using wait() and notify() in Java: common problems and mistakes
Using wait() and notify() in Java to implement a latch
Volatile arrays in Java
How to use wait()/notify() in Java
When to use wait()/notify() in Java
Concurrency
Programming with Threads in Java
Thread scheduling
Coordinating threads with CountDownLatch
Co-ordinating threads with a CyclicBarrier
Concordinating threads with a CyclicBarrier: error handling
Concordinating threads with a CyclicBarrier: parallel sort (1)
Concordinating threads with a CyclicBarrier: parallel sort (2)
Concordinating threads with a CyclicBarrier: parallel sort (3)
Concordinating threads with a CyclicBarrier: parallel sort (4)
Deadlock and how to prevent it
How threads work: more details
Threading with Swing: SwingUtilities.invokeLater
Thread priorities
What is Java 'thread priority'?
Processes and ProcessBuilder in Java
Processes in Java
Thread.sleep
Bugs and issues with Thread.sleep
Stopping a thread
Threading with Swing
Thread interruption in Java
Thread interruption in Java (ctd)
Thread methods in Java
Thread pools in Java
Controlling the queue with ThreadPoolExecutor
Constructing Threads and Runnables in Java
Synchronization and thread safety in Java
Thread scheduling
Thread scheduling (ctd): quanta and switching
Thread scheduling implications in Java
ThreadPoolExecutor
Frequent Java threading questions
The Thread.yield() method
Collections
Introductions to Collections (data structures) in Java
Implementing a hash table in Java with a 64-bit hash function
Implementing a hash table in Java with a 64-bit hash function (ctd)
Bloom filters in Java
Bloom filters: the false positive rate
Bloom filters: the false positive rate (analysis)
Bloom filters: the false positive rate (ctd)
Bloom filters in Java: example implementation
ConcurrentSkipListMap
Java Collections: overriding hashCode() and equals()
Advanced use of hash codes in Java
Advanced use of hash codes in Java: duplicate elimination
Advanced use of hash codes in Java: duplicate elimination with a BitSet
Advanced use of hash codes in Java: keying on hash code
Advanced use of hash codes in Java: statistics
Advanced use of hash codes in Java: doing away with the keys
Writing a hash function in Java: guide to implementing hashCode()
How the Java String hash function works
How the Java String hash function works (2)
Secure hash functions
Strong and secure hash functions
Strong (non-secure) hash functions
Java Collections: introduction to hashing
The mathematics of hash codes and hashing
The mathematics of hash codes and hashing: hash code statistics
Java Collections: hashing and hash maps
Java Collections: introduction to hashing and hash maps
Introduction to hashing and hash maps: improving the hash function
Introduction to hashing and hash maps: string hash functions
Java Collections: maps
PriorityQueue
Example of PriorityQueue: doing a Heapsort
Sorting data in Java: the compareTo() method of the Comparable interface
Sorting data in Java: the Comparable interface
Sorting data in Java: optimising the compareTo() method
Specifying how to sort data in Java: Comparators
Specifying how to sort data in Java: an example Comparator
Implementing an Insertion Sort in Java
Introduction to sorting data with Java collections
Performance of the Java sorting algorithm
Performance of the Java sorting algorithm (ctd)
Sorting data in Java: how to sort a list of Strings or Integers
A strong hash function in Java
A strong hash function in Java: example hash function
A strong hash function in Java: example hash function
Introduction to using collections in Java
Using collections in Java: enumerating items in a list
Using collections in Java: sets
Using collections in Java: maps and the HashMap
Using collections in Java: making your classes work with hash maps and hash sets
I/O
Introduction to Java I/O APIs
Reading a line at a time from a character stream in Java
ByteBuffer
Reading and writing to a byteBuffer
Reading and writing non-byte types in a byteBuffer
Reading character streams in Java
Listening for file system modifications
WatchServuce: Listening for file system modifications
Polling WatchService in a separate thread
WatchServuce: Listening for file system modifications
Introduction to Java input streams
How big should my input buffer be?
Buffering with Java input streams
Error handling with Java input streams
Introduction to networking in Java
Direct buffers
The Layout of a NIO buffer
NIO Buffer performance
Buffer data sources (and backing arrays)
Introduction to buffers in Java NIO
Reading and writing arrays to a NIO buffer
Reading and writing primitive arrays to a NIO buffer
NIO buffer types
How to set the byte order of a NIO buffer
NIO Channels
Mapped buffers (file mapping)
StreamCorruptedException
Introduction to networking
A simple client and server in Java
A simple client and server in Java: the "conversation" server-side
XML/Web
Introduction to XML in Java
XML parsing in Java with XPath
XML parsing in Java with XPath (ctd)
Parsing XML with SAX: creating a DefaultHandler
Parsing XML with SAX (in J2ME)
Using XPath from a Java Applet
AJAX programming: JavaScript event handlers
Java and AJAX programming: introduction
Java/AJAX programming: client-side web page manipulation
AJAX programming: server-side Java
AJAX programming: handling AJAX requests and responses from a Servlet
AJAX programming: using the XMLHttpRequest object
Java Servlets
Setting the Content-Length header from a Java Servlet
How to use Cookies with Java Servlets
The Java Cookie class: writing cookies
The Java Cookie class: reading cookies
The HTTP GET and POST methods explained
Reading HTTP request headers from a servlet: the referer header
The user-agent HTTP header
Setting the HTTP status (response) code from a Java Servlet
Getting started with servlet development
Keep-alive connections with Java Servlets
Tuning keep-alive connections with Java Servlets
Servlet programming: reading HTTP request parameters
Reading HTTP request headers from a servlet
Introduction to Java Servlets: How to pick a servlet hosting company
How to pick a servlet hosting company: Servlet installation and logistical issues
How to pick a servlet hosting company: recommended resource quotas
Handling sessions in a Servlet: introducing the Session API
Session synchronization using the Servlet Session API
Handling sessions in a Servlet
Setting the buffer size on the Windows command window
Java math operations
Mathematical operations in Java
Basic floating point operations in Java: performance and implementation
BigDecimal and BigInteger
Operations and performance of BigDecimal and BigInteger
Performance of the BigDecimal/BigInteger method()
Math.exp() in Java
Floating point primitives in Java
Methods of the java.util.Math class
Methods of the java.util.Math class (ctd)
Karatsuba's algorithm for multiplication
Generating random numbers in Java: the Java random class and beyond
Sources of entropy
Using random numbers for simulations: Random.nextGaussian()
Random.nextGaussian
Alternatives to java.util.Random
Using java.util.Random
How does java.util.Random work and how good is it?
Subclassing java.util.Random
Randomness of bits with LCGs
'java.lang.Random' falls "mainly in the planes"
Multiply-with-carry (MWC) random number generators
The Numerical Recipes ranom number generator in Java
How to pick a random sample from a list
The Java SecureRandom class
Seeding random number generators
Seeding random number generators: looking for entropy
XORShift random number generators in Java
Introduction to binary numbers
Binary representation in computing and Java
Bits and bytes: how computers (and Java) represent numbers
Number storage in computing: bits and bytes
Grouping bytes to make common data types and sizes
Converting to/from hexadecimal in Java
Compressing
Data compression using Deflater in Java
The deflate algorithm: dictionary compression in the Deflater
Huffman compression in the Deflater
Configuring the Java Deflater: compression level and strategy
How to compress data using Deflater in Java
Transforming data to improve Deflater performance
Reading GZIP files in Java
Reading ZIP files in Java
Reading ZIP files in Java: enumeration and metadata
Problems with ZIP files in Java
Cryptography
Java Cryptography
AES and block ciphers in Java
Asymmetric (public key) encryption in Java
Block modes with Java ciphers
Using block modes and initialisation vectors in Java
Comparison of encryption ciphers in Java
Collision attacks
Encryption: introduction
Secure hash functions in Java
Secure hash functions in Java (ctd)
The Initialisation Vector (IV)
Encryption key size
Encryption: keys
Password-based encryption
Password-based encryption
Password-based encryption
RSA encryption in Java: the RSA algorithm
RSA encryption in Java
RSA encryption in Java (ctd)
RSA key lengths
Symmetric-key encryption in Java
Removing the 128-bit key restriction
Databases
SQL Database access from Java
Closing JDBC resources
Connecting to a SQL database with JDBC
Using prepared statements with JDBC
Retrieving data from a ResultSet with JDBC
Executing a statement on a SQL database with JDBC
Exceptions
Introductions to Exceptions and error handling in Java
Exceptions in Java: when to catch and when to throw?
Exceptions in Java: the 'finally' block
The exception hierarchy in Java
Introducing Exceptions in Java
Recasting exceptions in Java
When to recast exceptions in Java
Throwing an exception in Java
Exceptions in Java: the throws declaration
Exceptions in Java: the try/catch block
How uncaught exceptions are handled in Java GUI applications
How uncaught exceptions are handled in Java
Unchecked exceptions in Java
How to
Java programming tutorial: arrays
Java programming tutorial: arrays (2)
Java programming tutorial: arrays (sorting)
Java programming tutorial: using 'if ... else'
Java programming tutorial: for loops
Java programming tutorial: nested 'for' loops
Java programming tutorial: 'if' statements
Java programming tutorial for beginners
Combining conditions: logical operators
Java programming tutorial: objects
Java programming tutorial: variable names
Java programming tutorial: variables
How to get started with Java
From BASIC to Java: an intrudction to Java for BASIC programmers
Java for BASIC programmers: event-driven programming
Java for BASIC programmers: libraries and OS access
Java for BASIC programmers: speed
Java for BASIC programmers: development process
From C to Java: an introduction to Java for C programmers
Java for C programmers: memory management
Java for C programmers: lack of pointers
Java for C programmers: error handling
Java for C programmers: class libraries
Java for C programmers: deployment model
How to get started with Java
Getting started with Java in NetBeans: adding your first line of Java code
Getting started with Java in NetBeans
Profiling & Perf
Java 5 profiling facilities
How to profile threads in Java 5: putting getThreadInfo() in a loop
How to profile threads in Java 5: using the ThreadMXBean
Thread profiling in Java 5: basic thread profiling methodology
Thread profiling in Java 5: Synchronization issues
Thread profiling in Java 5: Synchronization issues (2)
Memory usage in Java
How to calculate the memory usage of a Java array
Saving memory used by Java strings: a one-byte-per-character CharSequence implementation
Instrumentation: querying the memory usage of a Java object
Memory usage of Java objects: general guide
Memory usage of Java Strings and string-related objects
Memory usage of Java Strings and string-related objects
How to save memory occupied by Java Strings
Optimisations made by the Hotspot JIT Compiler
Getting started with JNI
The Java Native Interface (JNI)
JNI data types
The overhead of native calls in Java
Reflection
Introduction to the Java reflection API
Calling a method via reflection in Java: details
Listing system properties and environment variables in Java
Reading system properties and environment variables in Java
Regex
Introduction to regular expressions in Java
Java regular expressions: capturing groups
Java regular expressions: alternatives in capturing groups
Character classes in Java regular expressions
Using the dot in Java regular expressions
Using named character classes in Java regular expressions
Regular expression example: determining IP location from the referrer string
Regular expression example: determining IP location from a Google referrer string
Regular expression example: determining IP location from a Google referrer string (2)
Regular expression example: using multiple expressions to determine IP location from a referrer string
Regular expression example: scraping HTML data
Matching against multi-line strings with Java regular expressions
Java regular expressions: using non-capturing groups to organise regular expressions
Using the Java Pattern and Matcher classes
When to use the Java Pattern and Matcher classes
Repititon operators in Java regular expressions
Repititon operators in Java regular expressions: greedy vs reluctant
Search and replace with Java regular expressions
Search and replace with Java regular expressions: using Matcher.find()
Splitting or tokenising a string with Java regular expressions
Performance of string tokenisation with Java regular expressions
Basic regular expressions in Java: using String.matches()
Thread-safety with regular expressions in Java
UI
Swing: User Interfaces in Java
Anonymous inner classes
Java Applets
Java Applets: the JApplet class
Java Applets
Swing components gallery
Basic Swing concepts: events and listeners
Using JCheckBox
Using JComponent
JPanel and Box
Introduction to Swing layouts
Coping with different screen sizes
Text fields and labels
Giving your Java application a Windows look and feel
Internationalisation and localisation
The Java Collator class
graphics
Basic image creation in Java with BufferedImage
Performance of different BufferedImage types
Saving a BufferedImage as a PNG, JPEG etc
Setting individual pixels on a BufferedImage
Overview of digital audio
Overview of digital audio: sampling
Overview of digital audio: sampling
JavaSound: Dealing with audio in Java
Basic JavaSound concepts: mixers and lines
Basic JavaSound concepts: mixers and lines (ctd)
Techniques
Recursion in Java
How recursion works
Recursion in Java: memory constraints
How to return multiple values/objects from a Java method?
This is a new section still being uploaded. Please bear with us!