0

I am studying Java, Spring and POI. I see https://poi.apache.org/spreadsheet/quick-guide.html and follow it.
At "New WorkBook", next code exists.

Workbook wb = new XSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
wb.write(fileOut);
fileOut.close();

Running above code, it works well.
I found out that "Workbook" is NOT class BUT interface. I learned that interface HAVE TO be implemented. But I CANNOT found the implementation. Where is it implemented? What must I study to comprehend it?

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
blank_popup
  • 261
  • 1
  • 2
  • 13
  • 5
    `XSSFWorkbook` implements `Workbook` – George Mulligan Jan 13 '16 at 02:15
  • 1
    If you are using an IDE, such as Eclipse or IntelliJ, you can place your cursor on `XSSFWorkbook` and hit F3 or right click on it to jump to the definition of the class. If you are using just a simple editor and the command line, you can run a search in your file system for `XSSFWorkbook.java` and/or `XSSFWorkbook.class` to find the implementation. – Raul Santelices Jan 13 '16 at 02:24
  • @Raul Santelices Thank you your help! – blank_popup Jan 13 '16 at 03:21

2 Answers2

0

Oficial Oracle tutorial about interfaces: https://docs.oracle.com/javase/tutorial/java/concepts/interface.html

Alejandro Goñi
  • 532
  • 1
  • 3
  • 14
0

That is interface instance.
Details: Using an Interface as a Type

In short, you can create instance of interface.

Case 1: for anonymous class.

Workbook wb = new Workbook() {
// Some implementation
}

Case 2: Use it as type. (Yes! your case!)

Workbook wb = new XSSFWorkbook();

see also: Strategy Design Pattern in Java. It is very useful idea.

Stanley Ko
  • 3,383
  • 3
  • 34
  • 60