A long bigger than Long.MAX_VALUE

That method can’t return true. That’s the point of Long.MAX_VALUE. It would be really confusing if its name were… false. Then it should be just called Long.SOME_FAIRLY_LARGE_VALUE and have literally zero reasonable uses. Just use Android’s isUserAGoat, or you may roll your own function that always returns false. Note that a long in memory takes a fixed number of bytes. From Oracle: long: The long data type is a … Read more

A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1

Short answer: Right-click on the class that contains the main method. Click on “Run As”. Click on “Java Application”. The keyboard shortcut is: Shift+Alt+X J (while holding Shift and Alt, press X; then release Shift and Alt and press J). Long answer: To be honest, I am not 100% sure why this problem happens. It might be … Read more

“Missing return statement” within if / for / while

If you put a return statement in the if, while or for statement then it may or may not return a value. If it will not go inside these statements then also that method should return some value (that could be null). To ensure that, compiler will force you to write this return statement which is after if, while or for. But if you … Read more

Long vs Integer, long vs int, what to use and when?

Long is the Object form of long, and Integer is the object form of int. The long uses 64 bits. The int uses 32 bits, and so can only hold numbers up to ±2 billion (-231 to +231-1). You should use long and int, except where you need to make use of methods inherited from Object, such as hashcode. Java.util.collections methods usually use the boxed (Object-wrapped) versions, because they need to work for any Object, and … Read more

What is IllegalStateException?

Usually, IllegalStateException is used to indicate that “a method has been invoked at an illegal or inappropriate time.” However, this doesn’t look like a particularly typical use of it. The code you’ve linked to shows that it can be thrown within that code at line 259 – but only after dumping a SQLException to standard output. We can’t tell what’s wrong … Read more

EOFException – how to handle?

While reading from the file, your are not terminating your loop. So its read all the values and correctly throws EOFException on the next iteration of the read at line below: If you read the documentation, it says: Throws: EOFException – if this input stream reaches the end before reading eight bytes. IOException – the stream has … Read more

How to write a Unit Test?

I have a Java class. How can I unit test it? In my case, I have class does a binary sum. It takes two byte[] arrays, sums them, and returns a new binary array.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)