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 android.support.annotation.Nullable;

import java.util.List;

public class Main {
    @Nullable
    public static <T> T getOrNull(List<T> list, int position) {
        try {
            return list.get(position);
        } catch (Exception e) {
            return null;
        }
    }

    @Nullable
    public static <T> T getOrNull(T[] array, int position) {
        return position < 0 || position >= array.length ? null : array[position];
    }
}