Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.ArrayList;

public class Main {
    /**
     * 
     * @param s
     * @param delimeter
     * @param fieldsToBeKept: idxes of the fields to be kept
     * @return
     */
    public static ArrayList<Double> stringToDoubleList(String s, String delimeter, int[] fieldsToBeKept) {
        ArrayList<Double> ret = new ArrayList<Double>();
        ArrayList<Double> allFields = new ArrayList<Double>();
        for (int i = 0; i < fieldsToBeKept.length; i++) {
            ret.add(allFields.get(fieldsToBeKept[i]));
        }
        return ret;
    }

    public static ArrayList<Double> stringToDoubleList(String s, String delimeter) {
        String[] fields = s.split(delimeter);
        ArrayList<Double> ret = new ArrayList<Double>();
        for (int i = 0; i < fields.length; i++) {
            ret.add(Double.parseDouble(fields[i].trim()));
        }
        return ret;
    }
}