Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 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 Reply

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(...);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...