java-design-patterns
java-design-patterns copied to clipboard
Casting Issue
@MaheshMadushan can you explain what this issue is about?
Hi @iluwatar , There is a small casting issue.
Hi @MaheshMadushan @iluwatar . I'm beginner in java and during learning the java literals , I encountered one nice point which address this issue . In java integer literal can always be assigned to a long variable . However , to specify a long literal you will need to explicitly tell the compiler that the literal value is of type long . We can do this by appending an uppercase or lowercase L to the literal . Here in this case we have variable futureTime as type of long type but the literal assigned to it is of type integer . So here compiler first do the casting of 1000 * 1000 * 1000 * 1000 to an integer literal and then assigned it to futureTime . Solution to this problem is to use the long literal. For example :
- 1000L * 1000 * 1000 * 1000
- 1000 * 1000L * 1000 * 1000
- 1000 * 1000 * 1000L * 1000
- 1000 * 1000 * 1000 * 1000L These are few valid long literal we can use ( we can also use variation like 1000000000000L ) . I hope you got my point here .
I want to fix this issue! Thanks a lot. @iluwatar
Hi is this issue still up for taking, or is it closed? I would like to contribute
Fixed with https://github.com/iluwatar/java-design-patterns/pull/1994