Not sure what is meant by "...implicit narrowing is permitted only among byte, char, short, and int."
Assigning an int to a short requires a cast.
About Question com.enthuware.ets.scjp.v6.2.509 :
Moderator: admin
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.509 :
Hi,
Implicit narrowing happens only for constants. A cast is not required for says byte b = 10; even though 10 is an int.
HTH,
Paul.
Implicit narrowing happens only for constants. A cast is not required for says byte b = 10; even though 10 is an int.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Wed Nov 23, 2022 3:40 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.509 :
Are we supposed to know that 43e1 produces a double and 0x0123 produces a float?
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.509 :
You do need to know the ways in which you can write a double value (such as 1.0 or 43e1 ) and the ways in which you can write an integral value (such as 1 or 0x0123 ). You also need to know that an integer value can be assigned to a float variable without a cast.
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Fri Apr 12, 2024 11:09 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.509 :
I missed because I wasn't sure about what 0x0123 means, and I thought that 43e1 fits into a double. Sadly I was wrong...
Who is online
Users browsing this forum: No registered users and 35 guests