Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #13281
| From | Arved Sandstrom <asandstrom3minus1@eastlink.ca> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Compilation ....cannot find symbol |
| References | <4f774b5c$0$1390$4fafbaef@reader2.news.tin.it> |
| Message-ID | <b9Idr.6103$qw7.1141@newsfe08.iad> (permalink) |
| Organization | Public Usenet Newsgroup Access |
| Date | 2012-03-31 15:36 -0300 |
On 12-03-31 03:25 PM, linus wrote:
>
> java:46: cannot find symbol
>
> symbol : constructor ImagePanel(java.awt.Image)
> location: class Movimento.ImagePanel
>
> ImagePanel imagepanel = new ImagePanel(image0);
> 1 error
> BUILD FAILED (total time: 0 seconds)
>
>
>
>
> WHAT IS WRONG IN THIS CONSTRUCTOR ?
>
>
>
> private class ImagePanel extends JPanel {
>
> Image image;
>
> private Image ImagePanel(Image image ) {
> return this.image = image ;} }
>
A constructor has no return type. What you wrote there is a regular
instance method that takes an Image parameter and returns an Image.
I stand to be corrected, but I doubt you understood what it is that you
did there with
return this.image = image;
This is legal. It's just not good practise. In any case it's not what
you wanted, because you won't be returning anything from a constructor
once you've actually written one.
AHS
--
A fly was very close to being called a "land," cause that's what they do
half the time.
-- Mitch Hedberg
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Compilation ....cannot find symbol linus <linus@yahoo.com> - 2012-03-31 20:25 +0200 Re: Compilation ....cannot find symbol Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-31 15:36 -0300 Re: Compilation ....cannot find symbol Donkey Hottie <donkey@fredriksson.dy.fi> - 2012-03-31 23:22 +0300 Re: Compilation ....cannot find symbol Roedy Green <see_website@mindprod.com.invalid> - 2012-04-01 07:35 -0700
csiph-web