O
O
olejoman2016-08-15 14:22:02
Java
olejoman, 2016-08-15 14:22:02

Android SDK vs JDK autoboxing?

Good day to all! I began to quietly study development for Android, having little experience with Java. Sometimes autoboxing from Java does not work. For example, the method takes a String argument. in String. In Android, this does not happen, and when you explicitly give int when writing, the IDE does not swear. And autoboxing does not work already when the application is running, as a result of which it crashes.

Is there a difference in such trifles? Should I be more careful when using autoboxing and synthetic sugar?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tsimur_S, 2016-08-15
@olejoman

autoboxing is the process of converting primitives int,long double etc to their object wrapper version and vice versa. https://docs.oracle.com/javase/tutorial/java/data/... Passing an int instead of a string is something new and actually sounds like javascript.

M
Max, 2016-08-15
@mbelskiy

> explicitly you give int IDE does not swear
because setText for example has two definitions: when we give CharSequence or int inside. It is necessary to transfer strings from resources without transformations in the code. int is converted to a string only if there is an expression like:
String s = aString + int

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question