Need help with Java

Status
Not open for further replies.

mCACGj

Member
So I keep getting "variable result might not have been initialized" but I'm pretty sure I have.

import javax.swing.JOptionPane;

public class Z7
{
public static void main (String[] args)
{
String numStr, result;
int number, sum, again;

do
{
numStr = JOptionPane.showInputDialog ("Enter an integer: ");

number = Integer.parseInt(numStr);


for(int apple=1; apple<=number; apple++)


result = "The number is:" + (apple + number);


JOptionPane.showMessageDialog (null, result);

again = JOptionPane.showConfirmDialog (null, "Do Another?");
}


while (again == JOptionPane.YES_OPTION);
}
}

If you Java experts out there wouldn't mind tell me what I'm doing wrong.
 
Status
Not open for further replies.
Top Bottom