I'm trying to use an AWT List and the List collection in my program. How do I overcome the class name conflict?

Benoit Xhenseval

In such a case of name conflict:

If you need only one definition but your type-import-on-demand (using import xxx.yyy.*;) causes the conflict, use explicit import for the reference you need.

import java.awt.*;
import java.util.List; // if you need this List in your program.

If you need both in the same Java file, you will have to explicitly refer at least one.

import java.awt.*;
import java.util.List; // your can use "List" for this one.
....
   java.awt.List myAwtList = new java.awt.List();

   List myUtilList = new List();

For clarity, I would suggest to explicitly manage both in that case.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact