The placement of logic is wrong that is why you are getting the error:
You should be using :
a = b;
b = c;
c = a + b;
public class Fibonacci
{
public static void main(String[] args)
{
int a=0,b=1,c=0;
System.out.print(a+" ");
for(int i=1;i<10;i++)
{
a = b;
b = c;
c = a + b;
System.out.print(" "+c);
}
}
}
Output:
0 1 1 2 3 5 8 13 21 34