Java Java String Format toJava(final double[] doubles)

Here you can find the source of toJava(final double[] doubles)

Description

to Java

License

Open Source License

Declaration

public static String toJava(final double[] doubles) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toJava(final double[] doubles) {
        final StringBuilder builder = new StringBuilder(20 + doubles.length * 20);
        toJava(doubles, builder);/*from   w  w w.ja va2  s. co m*/
        return builder.toString();
    }

    /**
     * 
     * @param doubles
     * @param builder
     */
    public static void toJava(final double[] doubles, final StringBuilder builder) {
        if (doubles == null) {
            builder.append("null");
            return;
        }
        builder.append("new double[] {");
        if (doubles.length > 0) {
            builder.append(doubles[0]);
        }
        for (int i = 1; i < doubles.length; i++) {
            builder.append(", " + doubles[i]);
        }
        builder.append("}");
    }
}

Related

  1. convertToJavaClassname(final String classname, final Map replacement)
  2. convertToJavaIdentity(String original, boolean firstCharacterUpperCase, boolean normalize)
  3. convertToJavaUnicode(String input, Character start1, Character end1, Character start2, Character end2)
  4. toJava(CharSequence str)
  5. toJava(String name)
  6. toJava(String text)
  7. toJAVA(String unicode)
  8. toJavaBeanPropertyName(String prop)