How to fix an UnsatisfiedLinkError (Can’t find dependent libraries) in a JNI project

I’m pretty sure the classpath and the shared library search path have little to do with each other. According to The JNI Book (which admittedly is old), on Windows if you do not use the java.library.path system property, the DLL needs to be in the current working directory or in a directory listed in the Windows PATH environment variable. Update: Looks … Read more

Big Oh for (n log n)

Explanation: The outer for loop should be clear; it is executed n times. Now to the inner loop. In the inner loop, you take n and always divide it by 2. So, you ask yourself: How many times can I divide n by 2? It turns out that this is O (log n). In fact, the base of log is 2, but in Big-O notation, we remove … Read more

Best way to create enum of strings?

I don’t know what you want to do, but this is how I actually translated your example code…. Alternatively, you can create a getter method for text. You can now do Strings.STRING_ONE.toString();

Exception in thread “main” java.net.ConnectException: Connection refused: connect Socket Programming Java

There are 2 issues in your program: You use the port 80 which is part of the well-known ports or system ports (0 to 1023), so you need to launch your server with the admin rights or change it for 8080 for example. You forgot to call bw.newLine() after each bw.write(sendMessage) such that it waits for ever since on the other side you call br.readLine() which means that it … Read more

Difference between string object and string literal

When you use a string literal the string can be interned, but when you use new String(“…”) you get a new string object. In this example both string literals refer the same object: Here, 2 different objects are created and they have different references: In general, you should use the string literal notation when possible. It is easier … Read more

Iterator for a linkedlist

1) SortedLinkedList extends BasicLinkedList but both have this is wrong. If you want to inherit those field in the sub class, you should mark the variables as protected in the super class and remove them from the subclass. 2) Same goes for private class Node. You are declaring the Node class in both the SortedLinkedList and BasicLinkedList. What you should do is declare … Read more

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