The Java Tutorials – Interfaces

The Java Tutorials – Interfaces

Onwards into the Interfaces and Inheritance tutorial, starting with Interfaces. This is a short one, starting with an overview and moving onto the more interesting topic of how to evolve or update interfaces.

Continue reading “The Java Tutorials – Interfaces”

Advertisements

The Java Tutorials – Annotations

The Java Tutorials – Annotations

The Learning the Java Language trail moves onto Annotations. Annotations are a form of metadata that can provide data about the program and there is more to them than you might think…

Continue reading “The Java Tutorials – Annotations”

The Java Tutorials – Enums

The Java Tutorials – Enums

Just as you were thinking you were finally at the end of the Classes And Objects tutorial, along comes Enums!

  • Use enum types to represent a fixed set of constants.
  • The enum declaration defines a class which implicitly extends java.lang.Enum
  • The class includes a static values method that returns an array of all values.

Continue reading “The Java Tutorials – Enums”

The Java Tutorials – Method References

The Java Tutorials – Method References

Method References are part of Lambda Expressions in The Java Tutorials but that’s a pretty big topic so I’m splitting it out here. It’s also a little hard to follow the examples if you are not familiar with Generics.

When a lambda expression does nothing but call an existing method, it’s often clearer to refer to the existing method by name. We can do this with a Method Reference.

Continue reading “The Java Tutorials – Method References”

The Java Tutorials – Lambda Expressions

The Java Tutorials – Lambda Expressions

The next section deals with Lambda Expressions with are new to Java 8 and fairly mind-bending. A Lambda Expression is a more succinct version of an Anonymous Class.

Continue reading “The Java Tutorials – Lambda Expressions”

The Java Tutorials – Nested Classes

The Java Tutorials – Nested Classes

A large chunk of the Classes and Objects tutorial deals with Nested ClassesInner Classes, Local Classes,Anonymous Classes, Lambda Expressions, and Method References. All these provide ways to:

  • logically group classes that are only used in one place
  • increase use of encapsulation as the outer class can have private members that the inner class can access
  • create more readable and maintainable code

The end of the tutorial has some suggestions about which approach to use. I’m starting with this before diving into the detail:

Continue reading “The Java Tutorials – Nested Classes”

The Java Tutorials – Classes And Objects

The Java Tutorials – Classes And Objects

The Classes And Objects tutorial starts off gently enough but then gets increasingly more mind-bending as it dives into Inner Classes, Local Classes, Anonymous Classes, Lambda Expressions, Method References and introductions to Generics. It’s pretty long too so I’m splitting it out, starting with notes on the basics.

Continue reading “The Java Tutorials – Classes And Objects”