Java is case sensitive
n = Integer.parseInt(br.readline());
^
should be
n = Integer.parseInt(br.readLine());
문제
I am new to Java, coming from a C background. While trying to implement a Fibonacci Sequence,I received the following error:
error: cannot find symbol n = Integer.parseInt(br.readline()); ^ symbol: method readline() location: variable br of type BufferedReader
The program is as follows :
import java.io.*;
public class fibonacci
{
public static void main(String args[])throws IOException
{
int n;
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);
System.out.println("enter the value of n");
n = Integer.parseInt(br.readline());
int fib[];
fib[1]=1;
fib[2]=1;
for(int i=3; i<=n; i++)
{
fib[i] = fib[i-1] + fib[i-2] ;
}
System.out.println("the"+n+"th fibonacci term is "+fib[n]);
}
}
Kindly help.
해결책
Java is case sensitive
n = Integer.parseInt(br.readline());
^
should be
n = Integer.parseInt(br.readLine());
다른 팁
Because it should be readLine
instead of readline
. Please keep in mind that JAVA is case-sensistive. And please use the IDE, it will catch such mistakes even before compilation.