I'm very new in java.I have a question about Forward Referencing.A forward reference is a reference to a variable that has not yet been initialized. but when we do this in method , the type of error gets different ? in fact my question is when we initialize a variable in method with another variable , is this a usage of reference or not ?
public static void main(String[] args) {
int total=number + 10;
int number;
Error is :
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: variable number
Without a method:
class Person
{
int total=number + 10;
int number;
Error is :
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - illegal forward reference