Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6711675

(str) String.format(Object... args) for more compact coding

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Duplicate
    • P5
    • None
    • 7
    • core-libs

    Description

      A DESCRIPTION OF THE REQUEST :
      I request that the following convenience method is added to java.lang.String:

      public static String format(Object... args) {
          String.format(this, args);
      }



      JUSTIFICATION :
      An instance-method would allow simple String formatting to be done in a more compact and readable manner.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Adding the above method to java.lang.String would allow this convenient syntax:

         String s = "%1 is %2 years old".format(name, years);

      ... synonymous with the current ...

         String s = String.format("%1 is %2 years old", name, years);


      ACTUAL -
      (not applicable)

      ---------- BEGIN SOURCE ----------
      (not applicable)
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      (not applicable)

      Attachments

        Issue Links

          Activity

            People

              jgish Jim Gish (Inactive)
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: