In (default package) I have a class called "Bird" that has a "dialog" method.
I can create class Class1 in one package, for example:
public class Class1
{
public static void main(String[] args)
{
Bird b = new Bird("Alexander",true,5);
b.dialog("tweet!");
}
}
It really works, and I really see it tweet!in the console.
My question is: what do I need to add to the code if it Class1is in the package Fundamental(whereas the class Birdis in the "default package")? I get an error: "Bird type not recognized" in this case. Probably I should specify the package somehow.
Side questions: 1. What is a classpath and how do you change it? I have seen this term vaguely used in the context of several discussions related to packages, but none of them contain the clear examples that I just gave. 2. I have seen many times packages called xxx.bla.zzz - is that standard? I usually use a common name (not three separated). I understand that the package replaces Java with namespaces in other languages. If you have several solutions worth mentioning, I would appreciate it. Thank!
source
share