I am confused with the terminology and its use in the eclipse IDE.
It is my understanding that you can use the import keyword to reference specific classes/java files within a group of class/java files called packages. You can also reference an entire group of classes/java files by using a wildcard modifier end the end of the import statement. So why do this when you can just make the package statement at the top of the java src file instead of having to do an import?
for instance:
folder structure: myapp>graphics>.class1, .class2
instead of doing this: import myapp.graphics.*
we can do this right?: package myapp
so whey even have the import keyword? can't you just use package myapp and reference the class with say class1 example = class1();
Second, I tried to remove the package com.example.myapp
and just import the classes with import myapp.graphics.*
but it it gave me an error stating that "" does not match the expected package com.example.myapp
. one of the fixes for it was to move MainActivity.java to a default package
. I chose that option and it moved it to a default package and then I was able to use the import myapp.graphcis.*;
statement while leaving out the package myapp.graphics
statement without any errors.
I am confused. Also, what is a deauflt package? I read somewhere that it is bad practice to use a default package. why?
thanks.