• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The method foo(String) is undefined for the type Bar

 
Alexandru Bucur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using Eclipse and I created an additional package to the "default" one , named "alex", in the "...\alex\src\" . "default" is in the same directory.

In the default package I have a file "Clasa.java":


In the additional one I have a file named "Print.java" :


Now I get an error at line 5, in file "Clasa.java" : The method print(String) is undefined for the type Clasa

If I replace print with Print.print (and alex.Print with alex.*) it works, but that is kind of redundant .

Any help ?

Thanks a lot

-Alex
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

To import the static members of a class, you use "import static:"

import static alex.Print.*;

The way you've written it, you're importing all the classes in the nonexistent package alex.Print .
 
Alexandru Bucur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works!

Thank you for the solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic