Java

  1. Home
  2. Computing & Technology
  3. Java

Learn About Java

Find out what Java is, who created it, and why people choose to program with it.

Next Steps

Paul's Java Blog

Monday's Programming Question

Monday January 12, 2009

Today the programming question is a simple one about jumping out of loops. I think for the most part it's possible to write loops without the need for a break statement but sometimes it's convenient to do so.

The following program does not contain examples of well written loops or ones that need a break statement. It's purpose is to get you thinking about how the break statement changes the logical flow of the code: Read more...

Answer to Monday's Formatting Question

Sunday January 11, 2009

This week the programming task was focused on creating formatted Strings using the System.out.printf method.

More specifically you had to use the printf method to create formatted strings that display Math.PI to:

  • match the output of
    System.out.println(Math.PI);
  • only have two decimal places
  • have two decimal places and a positive sign (i.e., "+")
  • Read more...

Java Term of the Week: Inheritance

Saturday January 10, 2009

Seeing as the last few articles on object-oriented programming have focused on what inheritance is and how it can be used in Java, it seems a good time to recap on inheritance for the Java term of the week.

Inheritance is a way of defining an "is-a" relationship between a class and a more specialized version of that class. For example, if a Student class extends a Person class, then it should be the case that Student is-a Person. The subclass Student builds on the functionality of the superclass Person.

Object-Oriented Programming: Preventing Inheritance

Thursday January 8, 2009

Most classes will never be extended by another class. After all, inheritance is only useful when the right relationship between two classes exists and extending the functionality of a class is beneficial.

However, if a class you design might be used by other programmers it's important to consider the implications of any subclasses they create. It might the case that you do not want your class to be extended by another. Find out how to prevent your classes from being inherited.

Discuss

Community Forum

Explore Java

More from About.com

Java

  1. Home
  2. Computing & Technology
  3. Java

©2009 About.com, a part of The New York Times Company.

All rights reserved.