Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #13280 > unrolled thread
| Started by | linus <linus@yahoo.com> |
|---|---|
| First post | 2012-03-31 20:25 +0200 |
| Last post | 2012-04-01 07:35 -0700 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
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
| From | linus <linus@yahoo.com> |
|---|---|
| Date | 2012-03-31 20:25 +0200 |
| Subject | Compilation ....cannot find symbol |
| Message-ID | <4f774b5c$0$1390$4fafbaef@reader2.news.tin.it> |
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 ;} }
[toc] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom3minus1@eastlink.ca> |
|---|---|
| Date | 2012-03-31 15:36 -0300 |
| Message-ID | <b9Idr.6103$qw7.1141@newsfe08.iad> |
| In reply to | #13280 |
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
[toc] | [prev] | [next] | [standalone]
| From | Donkey Hottie <donkey@fredriksson.dy.fi> |
|---|---|
| Date | 2012-03-31 23:22 +0300 |
| Message-ID | <9l5k49-om3.ln1@hurricane.fredriksson.dy.fi> |
| In reply to | #13280 |
31.3.2012 21:25, linus kirjoitti:
> WHAT IS WRONG IN THIS CONSTRUCTOR ?
>
>
>
> private class ImagePanel extends JPanel {
>
> Image image;
>
> private Image ImagePanel(Image image ) {
> return this.image = image ;} }
It is not a constructor. There is no constructor i your sample.
--
FORTUNE PROVIDES QUESTIONS FOR THE GREAT ANSWERS: #5
A: The Halls of Montezuma and the Shores of Tripoli.
Q: Name two families whose kids won't join the Marines.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-04-01 07:35 -0700 |
| Message-ID | <bqpgn7h18vkq63slnd7onl7ak99ub4qmk4@4ax.com> |
| In reply to | #13280 |
On Sat, 31 Mar 2012 20:25:18 +0200, linus <linus@yahoo.com> wrote,
quoted or indirectly quoted someone who said :
> private Image ImagePanel(Image image ) {
> return this.image = image ;} }
that is not a constructor. Constructors don't return anything, even
void. You are confused between a static factory and a constructor.
See http://mindprod.com/jgloss/constructor.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web