Marcio, isso n�o funciona, pq n�o h� mensagem de erro criada. E ArrayIndexOutOfBoundsException � uma classe, n�o uma mensagem, e deve ser retornada pelo toString() ou pelo printStackTrace()
 
By API:
 
Class Throwable
 
getMessage
public String getMessage()
Returns the error message string of this throwable object.
Returns:
the error message string of this Throwable object if it was created with an error message string; or null if it was created with no error message
 
toString
public String toString()
Returns a short description of this throwable object. If this Throwable object was created with an error message string, then the result is the concatenation of three strings:
The name of the actual class of this object
": " (a colon and a space)
The result of the getMessage() method for this object
If this Throwable object was created with no error message string, then the name of the actual class of this object is returned.
Overrides:
toString in class Object
Returns:
a string representation of this Throwable.
 
 
Andr� Barbosa
 
 
----- Original Message -----
From: "Marcio Ricardo Hatzlhoffer Correia" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 31, 2003 11:19 AM
Subject: Re: [java-list] Exce��o/Duvida

> Utilize:
> int b[]=new int[10];
> try
>    {
>       System.out.print(b[23]);
>    }
> catch(ArrayIndexOutOfBoundsException e)
>    {
>       System.out.print(e.getMessage());
>    }
>
> ----- Original Message -----
> From: "Felipe Ferraz" <
[EMAIL PROTECTED]>
> To: <
[EMAIL PROTECTED]>
> Sent: Monday, March 31, 2003 10:36 AM
> Subject: [java-list] Exce��o/Duvida
>
>
>   Tenho uma classe com o seguinte codigo:
>
> int b[]=new int[10];
> try
>    {
>       System.out.print(b[23]);
>    }
> catch(Exception e)
>    {
>       System.out.print(e.getMessage());
>    }
>  que se nao tiver o try me retorna a velha mensagem de
> arrayoutofbounds e etc, mas quando eu pe�o para que ele
> imprima o e.getmessage ele apenas imprime null, pergunto,
> como eu fa�o para que o programe nao aborte, lance a exce��o
> mas a mensagem retornada seja a de arrayoutofbounds?
>
>
> ---
> UOL, o melhor da Internet
>
http://www.uol.com.br/
>
>
> ------------------------------ LISTA SOUJAVA ----------------------------
>
http://www.soujava.org.br  -  Sociedade de Usu�rios Java da Sucesu-SP
> d�vidas mais comuns:
http://www.soujava.org.br/faq.htm
> regras da lista: http://www.soujava.org.br/regras.htm
> historico: http://www.mail-archive.com/java-list%40soujava.org.br
> para sair da lista: envie email para [EMAIL PROTECTED]
> -------------------------------------------------------------------------
>
>
>
> ------------------------------ LISTA SOUJAVA ----------------------------
>
http://www.soujava.org.br  -  Sociedade de Usu�rios Java da Sucesu-SP
> d�vidas mais comuns:
http://www.soujava.org.br/faq.htm
> regras da lista: http://www.soujava.org.br/regras.htm
> historico: http://www.mail-archive.com/java-list%40soujava.org.br
> para sair da lista: envie email para [EMAIL PROTECTED]
> -------------------------------------------------------------------------

Responder a