Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #14326
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JavaFX Slider compile time error |
| Date | 2012-05-05 21:03 -0700 |
| Organization | albasani.net |
| Message-ID | <jo4t6p$tj7$1@news.albasani.net> (permalink) |
| References | <4fa58b39$0$41612$c3e8da3$3a1a2348@news.astraweb.com> <APednd33hPX6EzjSnZ2dnUVZ8gudnZ2d@giganews.com> <4fa5a141$0$20320$c3e8da3$9deca2c3@news.astraweb.com> |
On 05/05/2012 02:53 PM, Hiram Hunt wrote: > "Leif Roar Moldskred"<leifm@dimnakorr.com> wrote in message > news:APednd33hPX6EzjSnZ2dnUVZ8gudnZ2d@giganews.com... >> Hiram Hunt<hiramhunt@verizon.net> wrote: >>> Hello, >>> I have some code that gets compile time errors in >>> some places but not others. I don't understand why >>> one situation is apparently legal and the other is not. >>> Here is the copy-and-paste of a minimal example: >> >> I don't have a Java development environment at hand, but >> it looks like a problem with generics. >> >>> // Create a SliderBuilder with the setting of several >>> // properties omitted for the sake of a minimal example. >>> >>> SliderBuilder sliderbuilder = SliderBuilder >>> .create(); >> >> Try "SliderBuilder<?> sliderbuilder =" instead. >> > > Thanks Leif and Markspace. Using<?> worked both in the minimal > example and in the program I trimmed down to make the example. > Using SliderBuilder<SliderBuilder> didn't, but thanks also. > I understand some of how generic work, but not all. I assume > that some type information that is available in the expressions > that initialize okslider1 and okslider2 is lost by not including > the<?> in "SliderBuilder<?> sliderbuilder". Don't assume, research. Generics without generic parameters (the angle-bracket part) are known as "raw" types, and exist only for backward compatibility. They are an error, shown as a warning by compilers in lenient mode. You should regard generic parameters as mandatory in generic types. The wildcard '?' is a dodge to get around not knowing the type at compile time. If you know what the base (generic) type should be, you should specify it. It would be ridiculous for the base type of 'SlicerBuilder' to be 'SliderBuilder', wouldn't it? Admit it, you were just throwing shit at the wall to see what would stick, weren't you? Read the angle brackets as "of": 'SliderBuilder<Foo>' is "'SliderBuilder' of 'Foo'". What is 'SliderBuilder', anyway? Show a link to the Javadocs for it (which *surely* you've studied - right?), please. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JavaFX Slider compile time error "Hiram Hunt" <hiramhunt@verizon.net> - 2012-05-05 16:19 -0400
Re: JavaFX Slider compile time error Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-05 15:32 -0500
Re: JavaFX Slider compile time error "Hiram Hunt" <hiramhunt@verizon.net> - 2012-05-05 17:53 -0400
Re: JavaFX Slider compile time error Lew <noone@lewscanon.com> - 2012-05-05 21:03 -0700
Re: JavaFX Slider compile time error Lew <noone@lewscanon.com> - 2012-05-05 21:09 -0700
Re: JavaFX Slider compile time error markspace <-@.> - 2012-05-05 14:16 -0700
csiph-web