Author
Do cast from int to short
André Asantos
Ranch Hand
Joined: Nov 23, 2009
Posts: 234
Hi there, please could you see my code and tell me why I must also do cast of rangeDe5NumeroNoMaximo attribute
because that atributte also short typed...
thanks,
André AS
SP - Brazil
André AS
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Aug 07, 2010 10:05:46
0
http://java.sun.com/docs/books/jvms/second_edition/html/Concepts.doc.html#16021
André Asantos
Ranch Hand
Joined: Nov 23, 2009
Posts: 234
Hello to you David,
I joined your web link...
I read that the default value of long is 0L, ok but I can't use it right? Look at:
That shows compile-time error, why?
André AS
São Paulo - Brazil
André Asantos
Ranch Hand
Joined: Nov 23, 2009
Posts: 234
Should not that print their default value?
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Aug 07, 2010 11:08:41
0
http://java.sun.com/docs/books/jls/second_edition/html/defAssign.doc.html#25979
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12921
André Asantos wrote: Should not that print their default value?
Local variables inside methods, as you show in your example, do not have default values. You must initialize them to a value before you use them.
Only member variables (at the level of a class) are initialized with default values (0L in the case of a long).
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
subject: Do cast from int to short