Java, справочник разработчика.
Thisjavo® Notes for Professionals book is compiled from Stack Overflow. P.P.QUm.e.Qta.ti.Q.Q. the content is written by the beautiful people at Stack Overflow- Text content is released under Creative Commons BY-SA. see credits at the end of this book whom contributed to the various chapters, images may be copyright of their respective owners unless otherwise specified. This is an unofficial free book created for educational purposes and is not affiliated with official Java® group(s) or company(s) nor Stack Overflow, All trademarks and registered trademarks are the property of their respective company owners.
Object casting.
As with primitives, objects can be cast both explicitly and implicitly.
Implicit casting happens when the source type extends or implements the target type (casting to a superclass or interface).
Explicit casting has to be done Java. Справочник разработчикаwhen the source type is extended or implemented by the target type (casting to a subtype). This can produce a runtime exception (ClassCastException) when the object being cast is not of the target type (or the target's subtype).
Float floatVar = new Float(42.0f);
Number n = floatVar; //Implicit (Float implements Number)
Float floatVar2 = (Float) n; //Explicit
Double doubleVar = (Double) n; //Throws exception (the object is not Double)
Купить .
Теги: Java
Смотрите также учебники, книги и учебные материалы:
- Изучаем Python, том 1, Лутц М., 2019
- Начинаем программировать на Python, Гэддис Т., 2019
- Программирование на Python для начинающих, МакГрат М., 2015
- Java Script Notes For Professionals
- Java, справочник разработчика, Эванс Б.Д., Флэнаган Д., 2019
- Java, задачи по основам программирования, более 600 задач, около 150 задач с решениями, книга для школьников и не только, Канель Е.Г., Зэев Ф., 2019
- HTML5 Notes For Professionals
- Html5+css3, основы современного web-дизайна, Кириченко А.В., Хрусталев А.А., 2018