background preloader

Getting started in Java

Facebook Twitter

Organize all your interests naturally. The Java™ Tutorials. The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases. See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases. The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into "trails".

Trails Covering the Basics These trails are available in book form as The Java Tutorial, Sixth Edition. Creating Graphical User Interfaces Creating a GUI with Swing — A comprehensive introduction to GUI creation on the Java platform. Specialized Trails and Lessons Trails Covering the Basics. Explore your community of interests. Organize all your interests naturally. [How-To] Override equals() and hashCode()... Part 1. [How-To] Override equals() and hashCode()... Part 2. JDK 6 Collections-related APIs & Developer Guides. How to make a java class compatible with Set or Map. Home Collections intro Lists Maps Sets Which collection class? Sorting Hashing Advanced Video lecture: hash tables Bloom filters If you've read this site's hash function guidelines, or if you have prior knowledge of hashing, then you may have an idea of how to write the hash function itself. The basics: override hashCode() and equals() Put very simply, there are two methods that a class needs to override to make objects of that class work as hash map keys: public int hashCode(); public boolean equals(Object o); As you might expect, the hashCode() method is where we put our hash function.

The equals() method The equals() method must return true if the fields of the current object equal those of the object passed in, else return false. Example Now let's see an example. 1. How to choose which Java collection class to use? Home Collections intro Lists Maps Sets Which collection class? Sorting Hashing Advanced Video lecture: hash tables Bloom filters The Java Collections API provides a whole host of data structures, especially since the API was expanded in Java 5 (and again slightly in Java 6) to include concurrent collections. Basic approach to choosing a collection The overall approach I'd suggest for choosing is as follows: choose the general type of organisation that your data needs to have (e.g. map or list); without too much thought, this is usually fairly clear; then, choose the implementation of that type that has the minimum functionality that you actually require (e.g. don't choose a sorted structure if you don't actually need the data to be sorted).

In general, the algorithm that underlies each collection class is designed to be a good tradeoff between efficiency and certain minimal requirements. 1. The first three of these are really "bread and butter" collection types. Welcome to your account! Add anything from anywhere. Explore your community of interests. Share all of this!