//in Item.java
package com.amazon.sales.itemMaster;
public class Item {
public static void main(String[] args) {
}
}
Not sure if this is because of NetBeans file placement or what, but I created the above per page 41, and of course the compiler did not like the fact that package name did not match the file name! So what's the trick?
[HD Pg 41, Sec. 2.3.1 - important-points-about-the-unnamed-package]
Moderator: admin
-
- Posts: 221
- Joined: Mon Nov 26, 2018 2:43 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 41, Sec. 2.3.1 - important-points-about-the-unnamed-package]
There is no rule that correlates the name of the package and the name of the file! The rule is about name of the class (that too, only if the class is public) and the name of the file.
Check out the last para on page 39 titled "Directory in which source files should reside". Netbeans enforces this convention but this is not mandatory. Another reason to avoid the IDEs while studying for the certification. You will waste time chasing ghosts like this.
(I have requested the author to make this point clear in the book.)
Check out the last para on page 39 titled "Directory in which source files should reside". Netbeans enforces this convention but this is not mandatory. Another reason to avoid the IDEs while studying for the certification. You will waste time chasing ghosts like this.
(I have requested the author to make this point clear in the book.)
-
- Posts: 221
- Joined: Mon Nov 26, 2018 2:43 pm
- Contact:
Re: [HD Pg 41, Sec. 2.3.1 - important-points-about-the-unnamed-package]
Having just read page 39 and the quiz on page 42, I kind of figured it was netbeans' deal. Thanks for confirming it.
-
- Posts: 221
- Joined: Mon Nov 26, 2018 2:43 pm
- Contact:
Re: [HD Pg 41, Sec. 2.3.1 - important-points-about-the-unnamed-package]
By the way, what would be a technical (and/or business) reason to have an unnamed package?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 41, Sec. 2.3.1 - important-points-about-the-unnamed-package]
Unamed package makes it easy to write small test programs. I havent come across any business reason for it.
Paul.
Paul.
Who is online
Users browsing this forum: No registered users and 5 guests