boxing Questions
6
Solved
There is code:
struct A
{
int b;
}
class B
{
A a;
int b;
}
Questions are:
Is a in B boxed or not?
Is a in B located in stack or in heap?
Is b in A boxed or not?
Is b in A stack or in heap?...
Amass asked 5/10, 2011 at 8:34
9
Solved
I am reading "C# via CLR" and on page 380, there's a note saying the following:
Note The Enum class defines a HasFlag method defined as follows
public Boolean HasFlag(Enum flag);
Using thi...
6
There's a general advice to use Integer.valueOf(int) instead of new Integer(int) because of caching.
In JDK 5+, you should really use valueOf because Integer now caches Integer objects between -1...
9
Solved
How to convert byte[] to Byte[] and also Byte[] to byte[], in the case of not using any 3rd party library?
Is there a way to do it fast just using the standard library?
21
Solved
How do I convert int[] into List<Integer> in Java?
Of course, I'm interested in any other answer than doing it in a loop, item by item. But if there's no other answer, I'll pick that one as ...
Tamer asked 2/7, 2009 at 11:47
7
Solved
I'm creating a messaging system for use in an XNA game. My Message types are structs because I want them to behave in a Value Type way.
struct MyMessageType1 : IMessage {}
struct MyMessageType2 :...
3
Solved
I couldn't find a definitive answer for this seemingly simple question. If I write a method like this:
public Integer getAnInt() {
int[] i = {4};
return i[0];
}
is the return value autoboxed int...
Unthinkable asked 12/8, 2022 at 15:1
5
Solved
I expected array.array to be faster than lists, as arrays seem to be unboxed.
However, I get the following result:
In [1]: import array
In [2]: L = list(range(100000000))
In [3]: A = array.arra...
Tessi asked 21/4, 2016 at 19:16
1
If an int takes 4 bytes, why does System.Int32 takes 24 bytes when boxing an integer into an object?
For example:
int i = 3;
object o = i;
6
What is the difference between boxing/unboxing and type casting?
Often, the terms seem to be used interchangeably.
12
Solved
Why do we need boxing and unboxing in C#?
I know what boxing and unboxing is, but I can't comprehend the real use of it. Why and where should I use it?
short s = 25;
object objshort = s; //Boxin...
9
Solved
I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome.
Vickyvico asked 16/8, 2008 at 8:34
8
Solved
So I understand what boxing and unboxing is. When's it come up in real-world code, or in what examples is it an issue? I can't imagine doing something like this example:
int i = 123;
object o = i;...
1
Solved
public class Playground {
public static void main(String[] args) {
String s = "blah";
Character lclfs = s.contains("/") ? '/' : s.contains("\\") ? '\\' : null...
Mayonnaise asked 13/10, 2021 at 8:19
10
Solved
I'm looking for a way to write code that tests whether a value is boxed.
My preliminary investigations indicate that .NET goes out of its way to conceal the fact, meaning that GetType() and IsVal...
2
Solved
Looking at the methods available for Vec<T> I stumbled across
into_boxed_slice(self) -> Box<[T]>
String also has such a method (into_boxed_str(self)). The usefulness of having Der...
Skew asked 21/9, 2016 at 11:44
5
Solved
Java 8 provides Stream<T> specializations for double, int and long: DoubleStream, IntStream and LongStream respectively. However, I could not find an equivalent for byte in the documentation....
Northernmost asked 8/9, 2015 at 13:54
1
Say I have a primitive value which I need to assign to some field using reflection. I know for sure that field is of the same primitive value type.
Is it possible somehow to set this value withou...
Communication asked 2/12, 2015 at 15:14
1
Solved
I'm looking for a way to conver Vec<Box<u32>> to Vec<&u32>. Here is what I tried:
fn conver_to_ref(){
let test: Vec<Box<u32>> = vec![Box::new(1), Box::new(2)];
l...
7
Solved
It was very confusing to me to observe this situation:
Integer i = null;
String str = null;
if (i == null) { //Nothing happens
...
}
if (str == null) { //Nothing happens
}
if (i == 0) { //Nul...
Eringo asked 28/7, 2010 at 12:26
3
Solved
(As a result of doing the research to answer this question, I (think I have!) determined that the answer is "no." However, I had to look in several different places to figure this out, so I think t...
Slideaction asked 26/8, 2014 at 14:39
3
I'm confused about the generic type. I expect that 2.asInstanceOf[A] is cast to the type A, meanwhile, it's cast to Int.
Besides that, the input is java.lang.Long whereas the output is a list of In...
Deduction asked 4/3, 2020 at 7:41
2
Solved
I came across an extension method that applies to structs (SomeStruct) and returns whether or not the value is equal to the default(SomeStruct) (when the parameterless constructor is called).
publi...
Catwalk asked 24/4, 2016 at 11:1
3
Solved
In C#, value types can be boxed, which leads to certain comparison issues, specially for different types. Example: 2m == 2L returns true, but (object)2m == (object)2L returns false. My question is:...
2
Solved
Reading the JAVA 13 SE specification, I found in chapter 5, section 5.1.7. Boxing Conversion the following guarantee:
If the value p being boxed is the result of evaluating a constant
expressio...
Candace asked 1/1, 2020 at 19:11
1 Next >
© 2022 - 2024 — McMap. All rights reserved.