Amigo,
Inicialize a variavel, e de uma olhado no assunto Escopo de variaveis
int a, b;
a=b=0;
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 ) );
At 12:47 PM 21/05/2001 -0300, 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]
-------------------------------------------------------------------------