autoboxing Questions
6
Solved
How does following expression evaluated?
Student class :
public class Student
{
private Integer id;
// few fields here
public Integer getId()
{
return id;
}
public void setId(Integer id)...
Langobardic asked 13/12, 2011 at 11:50
2
In Scala there are 2 representations of double-precision numbers, one is an AnyVal, the other AnyRef. On the JVM they are mapped to the primitive double and the class java.lang.Double respectively....
Washhouse asked 10/10, 2011 at 21:2
3
Solved
We have a class LogManager in our Java project which looks like this:
public class LogManager {
public void log(Level logLevel, Object... args) {
// do something
}
public void log(Level logL...
Unsupportable asked 7/10, 2011 at 15:25
7
Solved
I am confused as to why Integer and int can be used interchangeably in Java even though one is a primitive type and the other is an object?
For example:
Integer b = 42;
int a = b;
Or
int d = 1...
Judiejudith asked 19/8, 2011 at 12:31
6
Solved
According to the documentation of the as operator, as "is used to perform certain types of conversions between compatible reference types". Since Nullable is actually a value type, I would expect a...
Thready asked 18/8, 2011 at 15:12
6
Solved
Java does not allow primitive types to be used in generic data structures. E.g. ArrayList<int> is not allowed. The reason is, primitive types can not be directly converted to Object. However ...
Dulsea asked 12/8, 2011 at 6:49
4
Solved
In the program below, the result is that 0.0 is considered less than Double.MIN_VALUE. Why?
We have a solution (work with Doubles only and use compareTo) and I want to understand why unboxing is f...
Rabbit asked 23/7, 2011 at 13:5
5
Solved
I really can'get my head around why the following happens:
Double d = 0.0;
System.out.println(d == 0); // is true
System.out.println(d.equals(0)); // is false ?!
This however works as expected:
...
Gowen asked 8/3, 2011 at 9:34
2
Following a suggestion by extempore recently about how to get scala to tell me whether there was boxing going on by looking at the bytecode, I created this class:
class X { def foo(ls : Array[Long...
Honkytonk asked 27/6, 2011 at 14:59
6
Solved
Autoboxing is rather scary. While I fully understand the difference between == and .equals I can't but help have the follow bug the hell out of me:
final List<Integer> foo = Arrays.asList(1...
Soulier asked 8/4, 2010 at 19:0
2
Java has both object, Integer, and primitive version, int, of basic types.
The primitive versions are faster/lighter/etc. so in general you should use them.
What I am wondering is why the designe...
Amblygonite asked 12/3, 2011 at 0:26
3
Solved
I am just wondering is there any difference in letting java autobox say an integer:
Integer myInteger = 3; // This will call Integer.valueOf()
or having your code as
Integer myInteger = Integer...
Guideboard asked 9/3, 2011 at 22:49
1
Solved
I'm a little confused by a warning that my Eclipse IDE is currently writing next to every expression where types are autoboxed or autounboxed:
The expression of type x is boxed into X
The express...
Toughie asked 18/2, 2011 at 8:31
2
Solved
I have a class that extends the LinkedList class.
Here's an excerpt of the code:
class SortedList<Integer> extends LinkedList<Integer> {
int intMethod(Integer integerObject){
return ...
Karrah asked 6/2, 2011 at 7:30
6
Solved
In java, I can write code like this
Boolean b = true ;
And it will work. I now have an object that holds the value "true".
How does that work? Why don't I have to pass the value through a const...
Disclose asked 3/2, 2011 at 19:37
3
Solved
How I can do that?
I have an arraylist, with float elements. (Arraylist <Float>)
(float[]) Floats_arraylist.toArray()
it is not working.
cannot cast from Object[] to float[]
Sweepback asked 29/1, 2011 at 15:7
2
Possible Duplicate:
Arrays.asList() not working as it should?
Apparently the return type of Arrays.asList(new int[] { 1, 2, 3 }); is List<int[]>. This seems totally broken to me...
Millard asked 6/1, 2011 at 17:7
4
Solved
In "Core java 1" I've read
CAUTION: An ArrayList is far
less efficient than an int[] array
because each value is separately
wrapped inside an object. You would
only want to use this construc...
Brotherly asked 29/12, 2010 at 20:45
1
Solved
Possible Duplicates:
Booleans, conditional operators and autoboxing
Java, Google Collections Library; problem with AbstractIterator?
The code below produces a NPE:
Integer test = nu...
Cummins asked 28/10, 2010 at 17:45
4
Solved
I'm a bit confused: I have a function, that takes an Object as argument. But the compiler does not complain if I just pass a primitive and even recognizes a boolean primitive as Boolean Object. Why...
Braces asked 30/8, 2010 at 13:18
3
Solved
Usually the compiler generates code to perform boxing and unboxing. But what does the compiler, if the boxed values are not needed? Is the (Oracle standard) compiler smart enough to optimize it awa...
Philippic asked 7/8, 2010 at 13:53
3
Solved
What is happening when a java.lang.Double object is initialized without using a call to the constructor but instead using a primitive? It appears to work but I'm not quite sure why. Is there some k...
Redeploy asked 20/7, 2010 at 13:57
3
Does anyone know of any style checkers or build tools that would flag autoboxing and unboxing from the build server?
I already have the eclipse option to flag it on my end, but not everyone in th...
Phiphenomenon asked 1/8, 2009 at 22:37
3
Solved
The following code throws NullPointerException:
int num = Integer.getInteger("123");
Is my compiler invoking getInteger on null since it's static? That doesn't make any sense!
What's happening?...
Arjan asked 26/6, 2010 at 9:18
9
Reference: http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html
"If your program tries to autounbox null, it will throw a NullPointerException."
javac will give you a compile-tim...
Savell asked 27/5, 2010 at 17:11
© 2022 - 2024 — McMap. All rights reserved.