Oi Roberto,
O erro est� no m�todo main da classe Folha3. Voc� s� esta
inicializando as vari�veis se o length dos args for maior que zero. Caso n�o
seja as vari�veis n�o ser�o inicializadas: a� voc� deve fazer algum tratamento
para esta situa��o, dependendo das regras do seu neg�cio.
Int� mais
Adelina
"Roberto A. Metz" wrote:
> Boa tarde ...
> Estou tentando fazer um pequeno programa que usa sobrecarga de metodos, mas
> impaquei num erro:
> --------------------------- Compiler Output ---------------------------
> Folha3.java:15: variable a might not have been initialized
> System.out.println( SobreCarga.multiplica ( a, b ) );
> ^
> Folha3.java:15: variable b might not have been initialized
> System.out.println( SobreCarga.multiplica ( a, b ) );
> ^
> 2 errors
> ----------------------------------------------------------------------------
> -
>
> Porque n�o inicialiadas? O que eu fiz de errado com as variaveis?
> Conto com ajuda dos mestres ...
>
> public class SobreCarga
> {
> public static double multiplica (int a, int b)
> {
> double total = ( a * b );
> return total;
> }
>
> public static double multiplica (double a, double b)
> {
> double total = ( a * b );
> return total;
>
> }
>
> public static double multiplica (int a, double b)
> {
> double total = ( a * b );
> return total;
> }
> }
>
> public class Folha3
> {
>
> public static void main (String[] args)
>
> int a, b;
>
> if (args.length > 0)
> {
> a = Integer.parseInt(args[0]);
> b = Integer.parseInt(args[1]);
> }
>
> System.out.println( SobreCarga.multiplica ( a, b ) );
> System.out.println( SobreCarga.multiplica ( a, b ) );
> System.out.println( SobreCarga.multiplica ( a, b ) );
>
> }
> }
> =================================
> Roberto A. Metz
> Universidade de Passo Fundo - RS
> [EMAIL PROTECTED]
> http://carazinho.upf.tche.br/~9430
> =================================
>
> ------------------------------ 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
> 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
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------