Oi, Luciana.

O erro est� na �ltima parte:
        for(int y=vetor.length;y>0;y--)
        {
                System.out.write(vetor[y]);
        }
Se voc� criou um vetor de 10 posi��es, ent�o o length retorna 10, s� que as 
10 posi��es s�o de 0 a 9. De cada voc� est� pedindo para o programa acessar 
vetor[10], que n�o existe. Fa�a:
        for(int y=vetor.length-1;y>=0;y--)
        {
                System.out.write(vetor[y]);
        }
Um abra�o e at� mais.
Leo.

----Original Message Follows----
From: Luciana Vieira <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Apresenta��o de vetor na ordem inversa
Date: Wed, 6 Sep 2000 10:49:41 -0700 (PDT)

Ol� pessoal,

Preciso ler um vetor de bytes e mostra-lo na ordem
inversa. Para isso escrevi o seguinte c�digo:

import java.io.*;
import java.lang.*;

class ler_inv
{
        public static void main(String args[])
        {
                byte vetor[]=new byte[10];
                int blidos=0;

                for(int i=0;i<10;i++)
                        vetor[i]=0;

                System.out.println("Escreva alguma coisa...");

                try
                {
                        blidos=System.in.read(vetor);
                        System.out.print("Voc� escreveu: ");
                        System.out.write(vetor,0,blidos);
                }
                catch(IOException erro)
                {
                        System.out.println("Tratamento de exce��o");
                }

                for(int y=vetor.length;y>0;y--)
                {
                        System.out.write(vetor[y]);
                }
        }
}

Este c�digo compila sem erros, mas quando vou
executar, leio o vetor e ap�s a leitura ocorre a
seguinte mensagem:
java.lang.ArrayIndexOutOfBoundsException at
ler_inv.main(ler_inv.java, Compiled Code) Exception in
thread "main"

Ser� que algu�m pode me ajudar.
Desde j� agrade�o
Luciana


__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
* Para n�o remover seu e-mail desta lista envie um e-mail para 
[[EMAIL PROTECTED]]
e no corpo do email escreva [unsubscribe [EMAIL PROTECTED]] ou acesse 
http://apoio.cits.br:8080/guest/RemoteListSummary/javabr
Veja as mensagens antigas em http://www.mail-archive.com/javabr%40cits.br/

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.

* Para n�o remover seu e-mail desta lista envie um e-mail para [[EMAIL PROTECTED]]
e no corpo do email escreva [unsubscribe [EMAIL PROTECTED]] ou acesse 
http://apoio.cits.br:8080/guest/RemoteListSummary/javabr
Veja as mensagens antigas em http://www.mail-archive.com/javabr%40cits.br/

Responder a