Initilization Error

Joined
Oct 11, 2008
Messages
2
Reaction score
0
Hi....

This is the function:

static void sumFun (float num1, float num2) throws IOException
{
BufferedReader read = new BufferedReader( new InputStreamReader(System.in));

String strNum1, strNum2;

System.out.println("Enter the first number: ");
strNum1 = read.readLine();

System.out.println("Enter the second number: ");
strNum2 = read.readLine();

num1 = Float.parseFloat(strNum1);
num2 = Float.parseFloat(strNum2);

}

This is in the main>> switch statement>> case1:

case 1:
sumFun(num11,num22);
System.out.println("The sum of " + (num11 + num22));
break;

And I have defined these before the switch statement:

float num11, num22;

But I received this error:

variable num11 might not have been initialized
variable num22 might not have been initialized


What's the wrong??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,779
Messages
2,569,606
Members
45,239
Latest member
Alex Young

Latest Threads

Top