How to properly compare two Integers in Java?

How to properly compare two Integers in Java?

I know that if you compare a boxed primitive Integer with a constant such as:Integer a = 4;if (a < 5)a will automatically be unboxed and the comparison will work.However, what happens when you are comparing two boxed Integers and want to co

Subset by group with data.table

Subset by group with data.table

Assume I have a data table containing some baseball players:library(plyr)library(data.table)bdt <- as.data.table(baseball)For each player (given by id), I want to find the row corresponding to the year in which they played the most games. T

How to initialize private static members in C++?

How to initialize private static members in C++?

What is the best way to initialize a private, static data member in C++? I tried this in my header file, but it gives me weird linker errors:class foo{ private: static int i;};int foo::i = 0;I'm guessing this is because I can't i

Socket options SO_REUSEADDR and SO_REUSEPORT, how do they differ? Do they mean the same across all m

Socket options SO_REUSEADDR and SO_REUSEPORT, how do they differ? Do they mean the same across all m

The man pages and programmer documentations for the socket options SO_REUSEADDR and SO_REUSEPORT are different for different operating systems and often highly confusing. Some operating systems don't even have the option SO_REUSEPORT. The W

Invalid argument supplied for foreach()

Invalid argument supplied for foreach()

It often happens to me to handle data that can be either an array or a null variable and to feed some foreach with these data.$values = get_values();foreach ($values as $value){ ...}When you feed a foreach with data that are not an array,

Facing an error “*** glibc detected *** free(): invalid next size (fast)”

Facing an error “*** glibc detected *** free(): invalid next size (fast)”

Please see MSO question A long list of possible duplicates — C memory allocation and overrunning bounds for information about closely related questions.Developer environment: CentOS 4.7, Kdevelop 3.1.1, gcc 3.4.6I run a Java test client tha

Strict Standards: Only variables should be passed by reference

Strict Standards: Only variables should be passed by reference

$el = array_shift($instance->find(..))The above code somehow reports the strict standars warning,but this will not:function get_arr(){ return array(1,2);}$el = array_shift(get_arr());So when will it report the warning anyway? 1:Consid

Variable might not have been initialized error

Variable might not have been initialized error

When i try to compile this: public static Rand searchCount (int[] x) { int a ; int b ; ... for (int l= 0; l

Libraries do not get added to APK anymore after upgrade to ADT 22

Libraries do not get added to APK anymore after upgrade to ADT 22

I have a rather big Android App project that is referencing several library projects. Everything was fine until i upgraded the eclipse ADT plugin to the newest version (v22). I also upgraded the SDK of course. I do not see any compile error

Returning data from async call in Swift function

Returning data from async call in Swift function

I have created a utility class in my Swift project that handles all the REST requests and responses. I have built a simple REST API so I can test my code. I have created a class method that needs to return an NSArray but because the API cal

What does the exclamation mark do before the function?

What does the exclamation mark do before the function?

!function () {}(); 1:JavaScript syntax 101. Here is a function declaration:function foo() {}Note that there's no semicolon: this is just a function declaration. You would need an invocation, foo(), to actually run the function.Now, when

ORA-00979 not a group by expression

ORA-00979 not a group by expression

I am getting ORA-00979 with the following query:SELECT cr.review_sk, cr.cs_sk, cr.full_name,tolist(to_char(cf.fact_date, 'mm/dd/yyyy')) "appt",cs.cs_id, cr.tracking_numberfrom review cr, cs, fact cfwhere cr.cs_sk = cs.cs_skand UPPER(cs.cs_i

What should my Objective-C singleton look like? [closed]

What should my Objective-C singleton look like? [closed]

My singleton accessor method is usually some variant of:static MyClass *gInstance = NULL;+ (MyClass *)instance{ @synchronized(self) { if (gInstance == NULL) gInstance = [[self alloc] init]; } return(gInstance);

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

I have some code and when it executes, it throws a IndexOutOfRangeException, saying, Index was outside the bounds of the array.What does this mean, and what can I do about it?Depending on classes used it can also be ArgumentOutOfRangeExce

Anonymous variables in Erlang

Anonymous variables in Erlang

What are the exact differences between underscore variables and a named variable that starts with underscore from the Erlang compiler point of view (apart from adding readability to the code)?For example are _ and _Var different? 1:The d

Which HTTP code to use for an empty subresource in a REST API?

Which HTTP code to use for an empty subresource in a REST API?

Let's say I've a resource articles at /articles.These articles may have related articles, so I fetch them by GETting /articles/{id}/related.What should I return is there is no related articles?I can think of:404 Not Found, maybe with an emp

Python unittest.TestCase object has no attribute 'runTest'

Python unittest.TestCase object has no attribute 'runTest'

For the following code:import unittestclass Test(unittest.TestCase): def test1(self): assert(True == True)if __name__ == "__main__": suite = unittest.TestSuite() suite.addTest(Test()) unittest.TextTestRunner().run(suite)U

C++: Create abstract class with abstract method and override the method in a subclass

C++: Create abstract class with abstract method and override the method in a subclass

How to create in C++ an abstract class with some abstract methods that I want to override in a subclass? How should the .h file look? Is there a .cpp, if so how should it look?In Java it would look like this:abstract class GameObject{ pu

Unrecognized selector sent to instance while archiving data (NSCoding)

Unrecognized selector sent to instance while archiving data (NSCoding)

-(void)transformObjects:(NSMutableArray*)array key:(NSString*)key{ NSMutableArray* archiveArray = [[NSMutableArray alloc]initWithCapacity:array.count]; for (Furniture *furniture in array) { // The error occurs on the line below

Splitting filenames using system file separator symbol

Splitting filenames using system file separator symbol

I have a complete file path and I want to get the file name.I am using the following instruction:String[] splittedFileName = fileName.split(System.getProperty("file.separator"));String simpleFileName = splittedFileName[splittedFileName.leng

Localizing attributed UITextView from storyboard

Localizing attributed UITextView from storyboard

I am using the storyboard and have a view where I have subclassed some UITextViews.My problem is that I am using ibtool --generate-strings-file to extract strings from the storyboard for localization and afterwards use ibtool -write on anot

convert vector to jobject in C++/JNI?

convert vector to jobject in C++/JNI?

I am using Java native function - public native ArrayList parseXML();In C++ my native function - vector resultList;JNIEXPORT jobject JNICALL Java_Sample1_parseXML(JNIEnv *env, jobject obj){ // logic return resultList; // here getting

emacs on mac os x, how to get spell check to work

emacs on mac os x, how to get spell check to work

I'm moving from Windows to Mac, and I've spent the whole night trying to get emacs to work. I've installed GNU emacs and simply copied over my Windows .emacs file, which seems to work ok, except for spell check. I installed cocoAspell and f

R error in unique.default(x) unique() applies only to vectors

R error in unique.default(x) unique() applies only to vectors

I created a dataset named state from the built-in matrix state.x77 with two continuous variables (Population and Income) and two factor variables (region and area).I computed mean income by region using tapply(), by(), aggregate(), and av

Adding git subtree from a branch

Adding git subtree from a branch

I'm trying to add a repo (called cow) to my project using git subtree add. In particular, I'd like to add the branch stable (which is not the master branch). I tried:git subtree add -P cow https://github.com/geoffryan/cow.git stableBut th