ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

DESARROLLO DE APLICACIONES CON MANEJO DE ARCHIVOS DE TEXTO Y EL MANEJO DE EXCEPCIONES EN JAVA


Enviado por   •  1 de Mayo de 2017  •  Ensayos  •  1.310 Palabras (6 Páginas)  •  160 Visitas

Página 1 de 6

Actividad 1

Alumno:
        Jesús María Matiz Salazar

Curso:
        DESARROLLO DE APLICACIONES CON MANEJO DE ARCHIVOS DE TEXTO Y EL MANEJO DE EXCEPCIONES EN JAVA

Excepciones Java

  1. ArrayIndexOutOfBoundsException
  2. ArrayStoreException
  3. ClassCastException
  4. CloneNotSupportedException
  5. EnumConstantNotPresentException
  6. IndexOutOfBoundsException
  7. NegativeArraySizeException

Instructor:
        GUSTAVO ADOLFO MURILLO PARAMO

//                PRIMER EJEMPLO DE TRY CATCH

// Esta excepción se presenta cuando se busca fuera del índice del array

                int[] valores = new int[3];

                valores[2] = 3;

                try{

                        System.out.println(valores[3]);

                }catch(ArrayIndexOutOfBoundsException ex){

                        System.out.println("Error 1 -> " + ex.toString());

                }

                

//                SEGUNDO EJEMPLO DE TRY CATCH

// Esta excepción se presenta cuando se trata de cambiar un objeto de un tipo a otro

                Object x[] = new String[3];                

                try{

                        x[0] = new Integer(0);

                }catch(ArrayStoreException ex){

                        System.out.println("Error 2 -> " + ex.toString());

                }

                

//                TERCER EJEMPLO DE TRY CATCH

// Esta excepion se presenta cuando se pretende castear un objeto de un tipo a otro

                try{

                        Object x2 = new Integer(0);

                        System.out.println((String)x2);

                }catch(ClassCastException ex){

                        System.out.println("Error 3 -> " + ex.toString());

                }

                

//        CUARTO EJEMPLO DE TRY CATCH

// Esta excepción se presenta cuando se pretende hacer un clon de un objeto padre sin // que este implemente la interface Cloneable

...

Descargar como (para miembros actualizados)  txt (3.6 Kb)   pdf (56.3 Kb)   docx (11.6 Kb)  
Leer 5 páginas más »
Disponible sólo en Clubensayos.com