Achat Cialis achat sildigra prof sublingual cialis professional 20 mg sildisoft acheter viagra pharmacie acheter propecia en ligne generique cialis pharmacie tadacip tadalafil silagra 25 achat levitra sans ordonnance acheter kamagra pas cher caverta en ligne kamagra liquide cialis soft tabs kamagra soft pharmacie

Foo cannot be resolved to a type

From JavaErrors

Jump to: navigation, search

When you got this error there are probably missing import in your .java file.

For example, code:

1 public class CannotBeResolved { 2 public static void main(String[] args) { 3 List list = 4 new ArrayList(); 5 } 6 }

Produces 2 error - line 3 and line 4:

List cannot be resolved to a type
ArrayList cannot be resolved to a type

When you add imports (lines 1 and 2):

1 import java.util.ArrayList; 2 import java.util.List; 3 4 public class ClassInstanceCreationExpressionTest { 5 public static void main(String[] args) { 6 List list = new ArrayList(); 7 } 8 }

error goes away :-) (You can replace both imports with only one java.util.*, but I'm using Eclipse and CTRL + SHIFT + o shortcut resolves classes = adds import, so I'm not using .* imports)

There is solution without imports, but I preffer the one with imports, code is imho more intelligible.

Without imports:

1 public class CannotBeResolved { 2 public static void main(String[] args) { 3 java.util.List list = new java.util.ArrayList(); 4 } 5 }

Maybe you are asking why there is not import for String class, answer is that java.lang.* classes do not need imports.

Links:

Personal tools