• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Two Questions about primitives and Bean Conventions

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey folks,

I got two issues that I cant explain myself.

1. Why is it possible to assign an integer literal like "50" to an short Referenz without casting it?


Okay... I guess the compiler is clever enough to handle this.
But if so, why does this thing not work as well:



The second issue is about valid Bean Conventions.
In K&B Study Guide 6 (thanks for the great book), they say:

Valid: add, remove, get, set, is

Later on there is a question where "add" is rendered as an invalid Bean declaration. Confusing, now what is correct?


Thanks an best regards,
Frank




 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Hinkel wrote:
Okay... I guess the compiler is clever enough to handle this.
But if so, why does this thing not work as well:


This is what the Java Language Specification says about it:

Method invocation conversions specifically do not include the implicit narrowing of integer constants which is part of assignment conversion (§5.2). The designers of the Java programming language felt that including these implicit narrowing conversions would add additional complexity to the overloaded method matching resolution process (§15.12.2).

 
Frank Hinkel
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Matthew, you hit the bull's eye.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Hinkel wrote:The second issue is about valid Bean Conventions.
In K&B Study Guide 6 (thanks for the great book), they say:

Valid: add, remove, get, set, is

Later on there is a question where "add" is rendered as an invalid Bean declaration. Confusing, now what is correct?


add and remove only apply to adding and removing event listeners. So addActionListener() is valid, but addParameter() isn't. Does that explain the case you're looking at?
 
Frank Hinkel
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does, thanks again Mr. Brown. :-)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic