aspose file tools*
The moose likes Beginning Java and the fly likes The method foo(String) is undefined for the type Bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "The method foo(String) is undefined for the type Bar" Watch "The method foo(String) is undefined for the type Bar" New topic
Author

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

Alexandru Bucur
Greenhorn

Joined: May 03, 2010
Posts: 2
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

Joined: Jul 08, 2003
Posts: 24184
    
  34

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 .


[Jess in Action][AskingGoodQuestions]
Alexandru Bucur
Greenhorn

Joined: May 03, 2010
Posts: 2
It works!

Thank you for the solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The method foo(String) is undefined for the type Bar