Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package logica; import java.util.ArrayList; import java.util.Random; import org.json.simple.JSONArray; /** * * @author estadm */ public class Array<T> { private ArrayList array; private ArrayList arrayPC; public Array() { array = new ArrayList(); arrayPC = new ArrayList(); } public int largo() { return array.size(); } public void llenar(int _CantidadMaxima) { Random rnd = new Random(); for (int i = 0; i < _CantidadMaxima; i++) { array.add(rnd.nextInt(1000)); } } public void llenarPC(int _CantMax) { for (int i = 0; i < _CantMax; i++) { arrayPC.add(i); } } public void imprimir() { for (int i = 0; i < array.size(); i++) { System.out.println(array.get(i)); } } public JSONArray crearJson(int tipo) { JSONArray Json = new JSONArray(); if (tipo == 0) Json.addAll(array); else Json.addAll(arrayPC); System.out.println(Json); System.out.println(Json.get(1)); return Json; } }