Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

import java.util.LinkedList;
import java.util.List;

public class Main {
    /**
     * Some code uses null to indicate "unset", which makes appending items complex.
     */
    public static List addCreate(List list, Object value) {
        if (null == list) {
            return singletonList(value);
        } else {
            list.add(value);
            return list;
        }
    }

    public static List singletonList(Object value) {
        List list = new LinkedList();
        list.add(value);
        return list;
    }
}