Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Copyright (c) 2005-2012 springside.org.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static <T extends Number> List<Long> guardTypeAsLong(List<T> numbers) {
        List<Long> longs = new ArrayList<Long>();
        for (int i = 0; i < numbers.size(); i++) {
            Number n = numbers.get(i);
            if (n instanceof Long) {
                longs.add(n.longValue());
            } else {
                longs.add(Long.parseLong(n.toString()));
            }
        }
        return longs;
    }
}