About question com.enthuware.ets.scjp.v6._2_.612
Moderator: admin
-
- Posts: 4
- Joined: Sat Aug 30, 2014 4:19 am
- Contact:
About question com.enthuware.ets.scjp.v6._2_.612
I don't think that is "Tough".
Last edited by admin on Mon Oct 13, 2014 10:46 am, edited 1 time in total.
Reason: Scrambled qid
Reason: Scrambled qid
-
- Posts: 27
- Joined: Mon Sep 22, 2014 1:30 pm
- Contact:
Re: About question com.enthuware.ets.scjp.v6.2.612
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?
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?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About question com.enthuware.ets.scjp.v6.2.612
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 *.
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 *.
-
- Posts: 27
- Joined: Mon Sep 22, 2014 1:30 pm
- Contact:
Re: About question com.enthuware.ets.scjp.v6.2.612
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.
import com.enthu.rad.*; (not: package com.enthu.rad.*;)
..in the first option, what I said would've made sense. Thanks.
Who is online
Users browsing this forum: Google [Bot] and 6 guests