Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
564 views
in Technique[技术] by (71.8m points)

illegal forward reference in java

 import java.io.*;
 import jxl.*;
 class Xlparsing
 {
   Workbook wb =wb.getWorkbook(new File(
    "C:\Documents and Settings\kmoorthi\Desktop\ak\new.xls"));
   // Illegal forward reference What it means
   Sheet st = wb.getSheet(0);
   Cell cell1 = st.getCell(0,0);
   String a1 = cell1.getContents();
   public static void main(String s[])
   {
     System.out.println(new Xlparsing().a1);
   }
 }

Hi When I tried to extract data from excel sheet illegal forward reference error comes in the file object creation.

How to resolve this?

question from:https://stackoverflow.com/questions/1746758/illegal-forward-reference-in-java

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

"Illegal forward reference" means that you are trying to use a variable before it is defined.

In this case, you are trying to invoke a method on wb in the declaration of wb.

Workbook wb = wb.getWorkbook(...);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...