primitive Questions

5

Solved

Is there an expandable array class in the Java API equivalent to the Vector or ArrayList class that can be used with primitives (int, char, double, etc)? I need a quick, expandable array for inte...
Rigorism asked 19/8, 2009 at 17:58

10

Solved

In my C# source code I may have declared integers as: int i = 5; or Int32 i = 5; In the currently prevalent 32-bit world they are equivalent. However, as we move into a 64-bit world, am I cor...
Dhu asked 2/10, 2008 at 21:13

0

Can someone give me explanation for the below sentence highlighted in Bold. "Primitive functions are only found in the base package, and since they operate at a low level, they can be more efficie...
Irrepressible asked 2/7, 2016 at 9:0

4

Solved

Following the advice provided in the question https://stackoverflow.com/questions/1738244/what-is-the-java-equivalent-of-net-bitconverter I have begun implementing my own bitconverter for Java but ...
Nunez asked 3/5, 2011 at 6:10

5

Option 1: String newStr = someStr + 3 + "]"; Option 2: String newStr = someStr + "3" + "]"; Which option is better with regards to performance, memory and general practice? What are some reco...
Luetic asked 8/2, 2013 at 23:7

2

Solved

Consider the following example code: public class TestClass { public void doSth(String str, String l, Object... objects) { System.out.println("A"); } public void doSth(String str, Object... ...
Christinchristina asked 19/5, 2016 at 20:9

6

Can someone please explain to me what is going on here: char c = '+'; int i = (int)c; System.out.println("i: " + i + " ch: " + Character.getNumericValue(c)); This prints i: 43 ch:-1. Does that m...
Louque asked 15/10, 2013 at 18:5

5

Solved

So, I've seen this line of code: Boolean variable = false; /* ..stuff.. */ if(variable.booleanValue() == false) { /* ..more stuff..*/ } And I've done, in a different place: Boolean variable = f...
Sandpit asked 13/4, 2016 at 9:47

2

I do not understand why here in case 1, it is not giving compilation error, contrary in case 2 (varargs), it gives compilation error. Can anyone please elaborate what differences the compiler...
Revolutionist asked 3/4, 2016 at 10:51

3

Solved

According to what I can find I believe DateTime is a primitive type but when I check my DateTime variable the property IsPrimitive is false. 7.3 Primitive Types (archive.org mirror) In the article ...
Slenderize asked 5/11, 2014 at 9:31

3

Solved

I am sure my question doesn't make sense, but it's because I don't know what I am seeing or how to describe it... The following code compiles fine, but it shouldn't because int is not the same ty...
Pickaxe asked 2/3, 2016 at 7:45

2

Solved

So I understand you can have object streams, i.e. Stream<T> and specialist primitive streams, e.g. IntStream, DoubleStream, etc. One of the benefits of the latter is to avoid autoboxing. Al...
Item asked 4/2, 2016 at 18:49

4

Solved

The following seemingly trivial problem has shaken the core of my understanding on how primitives work in Java. I have come across the term "implicit narrowing" whereby a variable of a smaller-ran...
Bechtold asked 12/1, 2015 at 5:22

4

Solved

What is the hashcode of a primitive type, such as int? for example, let's say num was an interger. int hasCode = 0; if (num != 0) { hasCode = hasCode + num.hashCode(); }
Tetracycline asked 9/8, 2012 at 19:43

6

In my application I use Jersey REST to serialize complex objects. This works quite fine. But there are a few method which simply return an int or boolean. Jersey can't handle primitive types (to m...
Upkeep asked 13/4, 2010 at 12:40

4

Solved

In the Google JavaScript style guide, it says not to use wrapper objects for primitive types. It says it's "dangerous" to do so. To prove its point, it uses the example: var x = new Boolean(false)...
Dumbwaiter asked 29/7, 2011 at 18:4

5

Solved

I have a byte[4096] and was wondering what the fastest way is to check if all values are zero? Is there any way faster than doing: byte[] b = new byte[4096]; b[4095] = 1; for(int i=0;i<b.lengt...
Gurrola asked 23/5, 2014 at 8:25

2

Solved

I'm reading Professional JavaScript for Web Developers 3rd ed. and in the summary of chapter 4 one can read: Two types of values can be stored in JavaScript variables: primitive values and refer...
Tittle asked 14/10, 2015 at 12:38

3

Solved

Consider the following two classes: public interface Foo<T> { public T moo(); } public class IntFoo implements Foo<Integer> { public int moo() { return 0; } } This code will pr...
Lx asked 5/9, 2015 at 22:59

2

Solved

What is the point of having a seperate unsigned type, aka NSUInteger if there is no guarantee (nor even, it seems, a chance) that you can assume, bet your bottom dollar on, or cry yourself to sleep...
Chokebore asked 2/8, 2012 at 5:48

1

Solved

I wrote my own class which converts C# standard primitives into byte arrays. Later on, I took a look at the BitConverter class source, to see how pros did it. My code example: public static byt...
Pressurecook asked 15/8, 2015 at 11:17

2

Solved

Here are two examples Map value as Single value private Map<Short, Boolean> _Booleans = new HashMap<Short, Boolean>(); //works private Map<Short, boolean> _Booleans = new HashMa...
Castleman asked 12/8, 2015 at 12:29

3

Solved

I read that all primitives fall under the System namespace. If I comment out using System I would expect there to be a build error in my program, however it is running successfully. Why is this?
Dric asked 8/8, 2015 at 14:20

1

Solved

I've been working a bit lately on implementing a binary network protocol in Scala. Many of the fields in the packets map naturally to Scala Shorts. I would like to concisely increment a Short varia...
Ferrate asked 6/8, 2015 at 21:46

3

Solved

Since the primitive double is represented with the java.lang.Double class, shouldn't double.class equal java.lang.Double.class? (This of course also happens on other primitive types too) System.ou...
Ecbatana asked 31/7, 2015 at 21:35

© 2022 - 2024 — McMap. All rights reserved.