Page 1 of 1

About question com.enthuware.ets.scjp.v6._2_.612

Posted: Sat Aug 30, 2014 6:37 am
by jbprek
I don't think that is "Tough".

Re: About question com.enthuware.ets.scjp.v6.2.612

Posted: Wed Oct 01, 2014 4:12 am
by piotrkmiotczyk
So in your question, to use Stock.class defined in com.enthu.rad package, I have to:
package com.enthu.rad;
...(place 'myself' in the same package)

Or I would have to, if I could, change:
import com.enthu.rad.*;
...to
import com.enthu.rad;
...because, as the solution reads: 'A package statement can never have a *. It should specify the exact package name'.
-------------------------------------------------------
Now, I have made a test package and:
import java.awt.event;
..does not compile, despite being 'exact package name', compiler is looking for a class name)
import java.awt.event.*;
...(import all classes in the package) works fine.

In other words, my test seems to suggest just the opposite. How come?

Re: About question com.enthuware.ets.scjp.v6.2.612

Posted: Wed Oct 01, 2014 6:22 am
by admin
Please post the exact code that you have a problem compiling.

The explanation says, "A package statement can never have a *. It should specify the exact package name", which is correct.
You are doing, "import java.awt.event;" This is not a package statement. This is an import statement. import statement should either end with a class name or with a *.

Re: About question com.enthuware.ets.scjp.v6.2.612

Posted: Wed Oct 01, 2014 7:51 am
by piotrkmiotczyk
You are completely right, I just kept overlooking the keyword. Had there been
import com.enthu.rad.*; (not: package com.enthu.rad.*;)
..in the first option, what I said would've made sense. Thanks.