Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2063 > unrolled thread
| Started by | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| First post | 2012-08-27 20:43 -0400 |
| Last post | 2012-08-29 08:26 -0700 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.java.help
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: newbie interface question Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-27 20:43 -0400
Re: newbie interface question Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-28 08:42 -0400
Re: newbie interface question Lew <lewbloch@gmail.com> - 2012-08-28 14:08 -0700
Re: newbie interface question Gene Wirchenko <genew@ocis.net> - 2012-08-28 17:21 -0700
Re: newbie interface question Roedy Green <see_website@mindprod.com.invalid> - 2012-08-29 08:26 -0700
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Date | 2012-08-27 20:43 -0400 |
| Subject | Re: newbie interface question |
| Message-ID | <k1h476$57q$1@dont-email.me> |
On 8/27/2012 7:17 PM, happytoday wrote:
> Dear All,
> I am testing interface but really I can not apply what is explained in
> oracle tutorials . Could you please explain why I have errors with
> this code :
> [...]
What "errors" do you have? For me, the code compiles just
fine, and runs producing the output
Cadence : 1 Gear : 1Speed:1
Cadence : 1 Gear : 1Speed:1
Cadence : 1 Gear : 1Speed:1
Cadence : 1 Gear : 1Speed:1
MB_Cadence : 1 MB_Gear : 1 MB_Speed :1
(Follow-ups set to c.l.j.help only, dropping c.l.j.programmer.)
--
Eric Sosman
esosman@ieee-dot-org.invalid
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Date | 2012-08-28 08:42 -0400 |
| Message-ID | <k1ieav$nqm$1@dont-email.me> |
| In reply to | #2063 |
On 8/28/2012 6:32 AM, happytoday wrote:
> On Aug 28, 2:43 am, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
>> On 8/27/2012 7:17 PM, happytoday wrote:
>>
>>> Dear All,
>>> I am testing interface but really I can not apply what is explained in
>>> oracle tutorials . Could you please explain why I have errors with
>>> this code :
>>> [...]
>>
>> What "errors" do you have? For me, the code compiles just
>> fine, and runs [...]
>>
>
> prog01_BicycleDemo_interface_trial01.java:62: printresults() in
> ACMEBicycle cannot implement printresults() in Bicycle; attempting to
> assign weaker access privileges; was public
> void printresults()
> ^
Aha! So by "this code" you meant "some other piece of code
altogether," right? Do you know how many times "ACME" appears
in the code sample you posted? Z E R O times, that's how many.
Unfortunately, I am not sufficiently skilled to debug code
that I cannot see. My guess (but I'm only guessing) is that
you've converted Bicycle from a class to an interface, thus
making its methods public automatically even if you don't use
the `public' keyword. Then (still guessing) you've written an
ACMEBicycle class that implements Bicycle, and you've tried to
give it an implementation of the printresults() method specified
by the Bicycle interface. But the interface says printresults()
must be a `public' method, while ACMEBicycle's printresults()
isn't marked `public'.
There are other possible explanations, but I'm tired of
guessing about unseen code and my Magic 8 Ball has a virus.
--
Eric Sosman
esosman@ieee-dot-org.invalid
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-08-28 14:08 -0700 |
| Message-ID | <57b88270-eafb-4cdc-b558-63dca0183366@googlegroups.com> |
| In reply to | #2064 |
Eric Sosman wrote: >happytoday wrote: >> Eric Sosman wrote: >>> happytoday wrote: >>>> I am testing interface but really I can not apply what is explained in >>>> oracle [sic] tutorials . Could you please explain why I have errors with >>>> this code : >>>> [...] >>> What "errors" do you have? For me, the code compiles just >>> fine, and runs [...] > >> prog01_BicycleDemo_interface_trial01.java:62: printresults() in >> ACMEBicycle cannot implement printresults() in Bicycle; attempting to >> assign weaker access privileges; was public >> void printresults() >> ^ > > Aha! So by "this code" you meant "some other piece of code > altogether," right? Do you know how many times "ACME" appears > in the code sample you posted? Z E R O times, that's how many. > > Unfortunately, I am not sufficiently skilled to debug code > that I cannot see. My guess (but I'm only guessing) is that > you've converted Bicycle from a class to an interface, thus > making its methods public automatically even if you don't use > the `public' keyword. Then (still guessing) you've written an > ACMEBicycle class that implements Bicycle, and you've tried to > give it an implementation of the printresults() method specified > by the Bicycle interface. But the interface says printresults() > must be a `public' method, while ACMEBicycle's printresults() > isn't marked `public'. > > There are other possible explanations, but I'm tired of > guessing about unseen code and my Magic 8 Ball has a virus. "All indications point to No!" The Magic Infinity Ball (you were looking at yours sideways) only answers "Yes" or "No" questions. Fortunately the OP asked a "Yes" or "No" question. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-08-28 17:21 -0700 |
| Message-ID | <3unq38tjr0kvgj4lj5o790qd267op92fr1@4ax.com> |
| In reply to | #2064 |
On Tue, 28 Aug 2012 08:42:06 -0400, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote:
[snip]
> There are other possible explanations, but I'm tired of
>guessing about unseen code and my Magic 8 Ball has a virus.
GIYF. There are many Web simulations of the Magic 8-Ball.
OP, GIYF, too. I suggest reading the following for how to ask
technical questions:
http://www.catb.org/~esr/faqs/smart-questions.html
How To Ask Questions The Smart Way
Eric Steven Raymond
and
http://sscce.org/
The SSCCE
Short, Self Contained, Correct (Compilable), Example
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-08-29 08:26 -0700 |
| Message-ID | <c4ds38de8g2hthadumg8haf7nao2aj6o2k@4ax.com> |
| In reply to | #2063 |
I think your problem is you don't know that all methods in interfaces are implicitly public, therefore when you implement them, they must remain public. -- Roedy Green Canadian Mind Products http://mindprod.com A new scientific truth does not triumph by convincing its opponents and making them see the light, but rather because its opponents eventually die, and a new generation grows up that is familiar with it. ~ Max Planck 1858-04-23 1947-10-04
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.help
csiph-web