java数组实现相关方法

import com.sun.corba.se.impl.orbutil.graph.Node;
import com.sun.corba.se.spi.presentation.rmi.IDLNameTranslator;

/**
 * Created by junyi.pc on 2017/1/25.
 */

public class Main {
   public int array[];
   public int length;
    public int max;

    public Main(int max){
        this.array=new int[max];
        this.max=max;
    }

    public void insert(int value) {
         if(length=array.length){
            throw  new ArrayIndexOutOfBoundsException();
        }
        else{
            for(int i=index;i=array.length){
           throw  new ArrayIndexOutOfBoundsException();
       }
        else{
           return  array[index];
       }
    }

    public static void main(String[] args){

        Main array = new Main(30);
        array.insert(1);
        array.insert(2);
        array.insert(3);
        array.insert(4);
        array.insert(5);
        //显示
        array.traversal();
    }
}

你可能感兴趣的:(java数组实现相关方法)