Hi,
I have a long piece of code that calculates two values (doubles) for me, I use this piece of code in a few places - to stick with DRY principles I should refactor this bit of code to a nice unit testable method. However I cant make it return two doubles, and doubles are primitive so cannot be passed by value and manipulated. The cle...
How can I cast a Java object into a boolean primitive
I tried like below but it doesn't work
boolean di = new Boolean(someObject).booleanValue();
The constructor Boolean(Object) is undefined
Please advise.
...
E4X (Ecma-357) is an extension to ECMAScript that adds XML literals as first-class primitives. That's awesome, but with only Mozilla and Adobe support (without V8 and IE support too), E4X is virtually dead from a web developer's perspective that has to support users with any modern browser.
What other work is being done around implemen...
I'm setting up my window like this:
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, form1.Width, form1.height, 0, 0, 1);
glMatrixMode (GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
And my drawing routine looks like this:
tempdist:=0.3 / distance(i,0,1,2);
xunit:=1 div 90;
zunit:=1 div 74;
glBegin(GL_LINE_LOOP);
case players[i...
I am trying to write my first DirectX 10 program that displays a triangle. Everything compiles fine, and the render function is called, since the background changes to black. However, the triangle I'm trying to draw with a triangle strip primitive is not displayed at all.
The Initialization function:
bool InitDirect3D(HWND hWnd, int w...
I'm attempting to define an extremely simple utility method that will save me from having to use a calculator to define RGB values as percentages. When I look into Apple's sample code called "QuartzCache", in the DrawView.m file, line 96, I see this:
float whiteColor[4] = {1, 1, 1, 1};
However, when I attempt to created a method like ...
I am designing an API. It will have a lot of methods which do the same, but have a different parameter primitives.
public void someMethod1(int x);
public void someMethod1(float x);
public void someMethod1(double x);
public void someMethod2(int x, int y);
...
public void someMethod3(int x, int y, int z);
...
Due to the primitives, I ha...
For example, do i need to lock 'bool' value when doing multithreading?
...
import java.lang.reflect.Array;
public class PrimitiveArrayGeneric {
static <T> T[] genericArrayNewInstance(Class<T> componentType) {
return (T[]) Array.newInstance(componentType, 0);
}
public static void main(String args[]) {
int[] intArray;
Integer[] integerArray;
intArray = (int[]) Array....
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 may not be cast to a reference type. Does Java know to create an Integer from the primitive int and then cast to the superclass...
How can we new primitive types in JNI. I have a function that returns a jobject. It is possible to return jint, jchar, etc.
There is NewString, why not NewInteger, NewCharacter, NewDouble, etc. There is no autoboxing at JNI layer at the moment.
I can go with the NewObject call, but this will be too much overhead to create primitive t...
For instance, there’s an integer column in a database table.
Then in java model, it can be mapped both as primitive int and Integer.
My question is what's difference between the int and Integer in this case? And performance concern?
Thanks!
...
Hello!
I have made a subclass of NSObject that is meant to be the model of my application. The class has a few methods and on instance primitive array as such:
@interface Cube : NSObject {
int cubeState[5][2][2];
}
- (void)printContent;
@end
@implementation Cube
- (id)init {
if (self = [super init]) {
for (int i=0...
So I have a XNA application set up. The camera is in first person mode, and the user can move around using the keyboard and reposition the camera target with the mouse. I have been able to load 3D models fine, and they appear on screen no problem. Whenever I try to draw any primitive (textured or not), it does not show up anywhere on the...
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 my knowledge), probably because they're no annotated and Jersey has no default annotation for them. I worked around that by creating complex ty...
I'll cut a really long story short and give an example of my problem.
Given a class that has a pointer to a primitive type as a property:
@interface ClassOne : NSObject
{
int* aNumber
}
@property int* aNumber;
The class is instantiated, and aNumber is allocated and assigned a value, accordingly:
ClassOne* bob = [[ClassOne alloc] in...
So, you know how the primitive of type char has the size of 1 byte? How would I make a primitive with a custom size? So like instead of an in int with the size of 4 bytes I make one with size of lets say 16.
Is there a way to do this? Is there a way around it?
...
Hi,
I was wondering if someone could explain how the following code works:
public interface Result {
public int getCount();
public List<Thing> getThings();
}
class SomeClass {
...
public Result getThingResult() {
final List<Thing> things = .. populated from something.
final int count = 5;
return new Result {
...
Why Generics (in Java) works with the objects but not with primitive types?
For example
Gen<Integer> inum = new Gen<Integer>(100); // works fine, but
Gen<int> inums = new Gen<int>(100); // is not allowed.
Thanks !
...
in Objective-c I have this function prototype:
-(NSString*)formatSQL:(NSString*) sql, ...
I may pass to this function any type of parameters: NSString, NSNumber, integer, float
How can I determine in the function if a parameter is an object (NSString..) or a primitive (integer...)?
thanks
BrochPirate
...