×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Stuardo Lucho Romero
Added: Sep 12, 2018 4:39 PM
Views: 3334
Tags: no tags
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication1;
  7.  
  8. import java.util.ArrayList;
  9. import java.util.Arrays;
  10. import java.util.HashMap;
  11. import java.util.List;
  12.  
  13. /**
  14.  *
  15.  * @author DTI
  16.  */
  17. public class JavaApplication1 {
  18.  
  19.     /**
  20.      * @param args the command line arguments
  21.      */
  22.     public static void main(String[] args) {
  23.         // TODO code application logic here
  24.        
  25.        
  26.         Persona[] arreglo = new Persona[4];
  27.         arreglo[0] = new Persona("Juan");
  28.         arreglo[1] = new Persona("Pedro");
  29.         arreglo[2] = new Persona("David");
  30.         arreglo[3] = new Persona("Carlos");
  31.        
  32.         ArrayList<Persona> listaP = new ArrayList<>(Arrays.asList(arreglo));
  33.         listaP.remove(1);
  34.         arreglo = listaP.toArray(new Persona[listaP.size()]);
  35.        
  36.        
  37.        
  38. //        System.out.println(arreglo[1].getNombre());
  39.        
  40.         ArrayList<Persona> lista = new ArrayList<>();
  41.         lista.add(new Persona("Juan"));
  42.         lista.add(new Persona("Pedro"));
  43.         lista.add(new Persona("David"));
  44.         lista.add(new Persona("Carlos"));
  45.         lista.remove(1);
  46.        
  47.         System.out.println(lista.get(1).getNombre());
  48.        
  49.         HashMap<String,Integer> hash = new HashMap<>();
  50.         hash.put("Daniel", 123456);
  51.         hash.put("El jefe", 654321);
  52.         hash.put("el presi", 000000);
  53.         hash.put("Daniel", 112233);
  54.        
  55.         System.out.println(hash.get("Daniel"));
  56.        
  57.        
  58.        
  59.     }
  60.    
  61. }
  62.