集册 Java实例教程 按索引从数组中获取值

按索引从数组中获取值

欢马劈雪     最近更新时间:2020-01-02 10:19:05

483
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
按索引从数组中获取值


//package com.nowjava;/* 来自 n o w j a   v  a . c o m - 时  代  Java*/


public class Main {

    public static void main(String[] argv) throws Exception {

        String[] array = new String[] { "1", "abc", "level", null,

                "nowjava.com", "asdf 123" };

        int indexOf = 2;

        System.out.println(getValue(array, indexOf));

    }


    public static String getValue(String[] array, int indexOf) {

        return getValue(array, indexOf, null);
        /*
        来 自*
         NowJava.com - 时  代  Java
        */

    }


    public static String getValue(String[] array, int indexOf,

            String d
展开阅读全文