在java
double number = (double) integer;This would give you access to all of the methods and properties of the MyClass class。
何時使用casting
鑄造如果無法正確完成,則可能是危險的。如果將對象施放為不正確的類型,則將獲得ClassCastException。重要的是要注意鑄造所涉及的風險,並且只有在確定對像是正確類型的情況下才能做到的。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3