java.net.ConnectException: Connection refused

This exception means that there is no service listening on the IP/port you are trying to connect to: You are trying to connect to the wrong IP/Host or port. You have not started your server. Your server is not listening for connections. On Windows servers, the listen backlog queue is full.

How does Java’s PriorityQueue differ from a min-heap?

Add() works like an insertWithPriority. You can define priority for the type that you want using the constructor: look under https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/PriorityQueue.html The order the Comparator gives will represent the priority in the queue.

How to avoid java.util.ConcurrentModificationException when iterating through and removing elements from an ArrayList

Two options: Create a list of values you wish to remove, adding to that list within the loop, then call originalList.removeAll(valuesToRemove) at the end Use the remove() method on the iterator itself. Note that this means you can’t use the enhanced for loop. As an example of the second option, removing any strings with a … Read more

“PKIX path building failed” and “unable to find valid certification path to requested target”

Go to URL in your browser: firefox – click on HTTPS certificate chain (the lock icon right next to URL address). Click “more info” > “security” > “show certificate” > “details” > “export..”. Pickup the name and choose file type example.cer chrome – click on site icon left to address in address bar, select “Certificate” … Read more

Converting array to list in Java

In your example, it is because you can’t have a List of a primitive type. In other words, List<int> is not possible. You can, however, have a List<Integer> using the Integer class that wraps the int primitive. Convert your array to a List with the Arrays.asList utility method. See this code run live at IdeOne.com.

‘Java’ is not recognized as an internal or external command

You need to configure your environment variables, JAVA_HOME and PATH. JAVA_HOME must contain the path to java, and you should add %JAVA_HOME%\bin to PATH Alternatively, you can simply add to your PATH the whole path to the bin folder, without the JAVA_HOME variable, however, this makes a little more annoying when you need to have … Read more

What is the meaning of “this” in Java?

Normally, I use this in constructors only. I understand that it is used to identify the parameter variable (by using this.something), if it have a same name with a global variable. However, I don’t know that what the real meaning of this is in Java and what will happen if I use this without dot … Read more

javax vs java package

I think it’s a historical thing – if a package is introduced as an addition to an existing JRE, it comes in as javax. If it’s first introduced as part of a JRE (like NIO was, I believe) then it comes in as java. Not sure why the new date and time API will end … Read more

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