Java Array Convert to arrayToJava(double[] v, int off, int len, String name)

Here you can find the source of arrayToJava(double[] v, int off, int len, String name)

Description

array To Java

License

Open Source License

Declaration

static String arrayToJava(double[] v, int off, int len, String name) 

Method Source Code

//package com.java2s;
/*//  w  w  w .j a  va 2s  . c o  m
 * Copyright (c) 2014, Massachusetts Institute of Technology
 * Released under the BSD 2-Clause License
 * http://opensource.org/licenses/BSD-2-Clause
 */

public class Main {
    static String arrayToJava(double[] v, int off, int len, String name) {
        String dec = "    private static final double[] " + name + " = { ";

        StringBuilder s = new StringBuilder();
        for (int i = 0; i < dec.length(); i++) {
            s.append(' ');
        }

        String prefix = s.toString();
        s = new StringBuilder(dec);

        for (int i = 0; i < len; i++) {
            if (i > 0) {
                s.append(",\n").append(prefix);
            }
            s.append(v[i + off]);
        }

        s.append("\n    };");

        return s.toString();
    }
}

Related

  1. arrayToCamelCase(String[] nameArray, int start, int end)
  2. arrayToCSL(String[] vals)
  3. arrayToDouble(final byte[] array, final int start)
  4. arrayToHTMLString(Object[] objectArray, int indent)
  5. arrayToInt(final byte[] array, final int start)
  6. arrayToJson(int[] x)
  7. arrayToLine(Object[] source)
  8. arrayToLines(String[] lines)
  9. arrayToLowercase(String[] array)