Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-12

Example in Javadoc for ToStringBuilder wrong for append.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.0
    • None
    • None
    • Operating System: other
      Platform: Other

    • 16076

    Description

      The following is directly from the Javadoc page. Please see inline notes.

          • Begin Quote ***
            To use this class write code as follows:

      public class Person {
      String name;
      int age;
      boolean isSmoker;

      ...

      public String toString()

      { return new ToStringBuilder(this). append(name, "name"). //!! should be - append("name", name). append(age, "age"). //!! should be - append("age", age). append(smoker, "smoker"). //!! should be - append("smoker", smoker). toString(); }

      }

          • End Quote ***

      In short, the order of arguments to the append method in the example have been
      reversed.

      Thank you.

      Attachments

        Activity

          People

            Unassigned Unassigned
            schrader005@yahoo.com Ted J Schrader
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: