• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 868
  • Last Modified:

incompatible

Hi experts,
this line is giving me an error:
 List list = new ArrayList();

I get : incompatible types;found   : java.util.ArrayList,required: java.awt.List at line 1445, column 17

whats the problem?
0
Samooramad
Asked:
Samooramad
  • 4
  • 2
  • 2
2 Solutions
 
girionisCommented:
Cast the "list" to a List when you pass it to the method call:

(List) list
0
 
mmuruganandamCommented:
>> List list = new ArrayList();

You don't need to cast, as the ArrayList implements the java.util.List

>> java.util.ArrayList,required: java.awt.List at line 1445, column 17

But java.awt.List is imported wrongly in your code.
So remove that import and change that to java.util.List
0
 
girionisCommented:
Nice catch :)

Yes mmuruganandam ir right, it is expecting an awt not a util list. You either need to pass a java.awt.List or chaneg the parameter method to accept a java.util.List.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
SamooramadAuthor Commented:
I dont pass it. I just use it in a method. Im also getting error for these lines:

list.add(myArray[i]);

return (myClass[]) list.toArray(new myClass[0]);

both give me cannot resolve symbol method
0
 
SamooramadAuthor Commented:
yep that worked :)
thank you
0
 
girionisCommented:
You can only add String to a java.awt.List.
0
 
mmuruganandamCommented:
cool ;)
0
 
girionisCommented:
:)
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now