Let's say that I have the following:
int a = 2; Number b = (Number) a; System.out.println(b); // Prints 2
http://java.sun.com/docs/books/jls/first_edition/html/15.doc.html#238146 says that a primitive value cannot be passed to a reference type. Does Java know to create an Integer from a primitive int and then pass it to a superclass? How exactly does Java handle this behind the scenes? Thank!
This process is called autoboxing . In short, the compiler sees that it needs a wrapper ( Integer), not a primitive ( int), and automatically adds the conversion. And in fact, your tide is Numbernot needed.
Integer
int
Number
Source: https://habr.com/ru/post/1737409/More articles:How can I switch time zones in Perl Template :: Plugin :: Date? - timezonehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1737404/how-to-pass-additional-convert-options-to-paperclip-on-heroku&usg=ALkJrhi6vfThDs3GyTxHrHIW03i8tFckpAThe problem with full-text search - sql-serverRemoving noise words in SQL Server 2005 full-text indexing - sql-server-2005WSDLs created by Axis2 services cannot be read by SoapUI or WSDL2Java - javaValidation Application Block and .NET Code Code Contracts - .netSynchronize my web page with the server when a connection is available (offline AKA) - javascriptПроблема с двунаправлением ManyToOne - javaGet current cross-platform time in C ++ - c ++trigger an event using jQuery live or delegate - jqueryAll Articles