# Numbers2.java:19: error: variable product might not have been initialized



## crowleyc625 (Mar 2, 2011)

I keep getting this error when trying to execute the returning value for the product method. I cannot figure this one part out \. i have went over the book a million times please help. this is java code by the way.


//Created 7/18/12
//file name Numbers2.java

public class Numbers2
{
public static void main(String[] args)
{
//declare variables
int num1 = 10;
int num2 = 20;
int product;

Sum(num1, num2);
System.out.println();
Difference(num1, num2);
System.out.println();
System.out.println("the product is: ");
Product(num1, num2, product);
}

public static void Sum(int num1, int num2 )// calculates the sum
{
int sum;
sum = num1 + num2;
System.out.print("the sum is: ");
System.out.println(sum);
}// end method

public static void Difference(int num1, int num2)// calculates the difference
{
int diff;
diff = num2 - num1;
System.out.print("the difference is: ");
System.out.println(diff);
}// end method


public static int Product(int num1, int num2, int product)
{
int neVal;
neVal = num1 * num2;
neVal = product;
return neVal;
}
}

that's the code and this is the error I'm getting.

----jGRASP exec: javac -g Numbers2.java

Numbers2.java:19: error: variable product might not have been initialized
Product(num1, num2, product);
^
1 error

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

the program requirements ask me to set the values for num1 and num2 in the main method.


----------

