wood burning stoves
The moose likes Java in General and the fly likes valid and invalid declarations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "valid and invalid declarations" Watch "valid and invalid declarations" New topic

valid and invalid declarations

abhay patil

Joined: Apr 26, 2007
Posts: 9
Which of the following are not a valid declarations?
A1 float f = 1;
A2 float f = 1.2f;
A3 float f = 1.2;
A4 float f = (float)1.2;
In this case float f =1 is a valid declaration. Can any one help me why this declaraion is a valid declaration.
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401

This is a Widening Primitive Conversion. int types can be implicitly converted to float, double and long. Please, check the following articles:

[ May 02, 2007: Message edited by: Leandro Melo ]

Leandro Melo
SCJP 1.4, SCWCD 1.4
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: valid and invalid declarations
It's not a secret anymore!