First, DON'T distribute the Java runtime with your app unless you know EXECTLY what you're shipping. Oracle has changed the licensing a couple times over the last five years, and, depending on which version you're shipping, you and/or your customers can be charged a monthly fee for the version you're using.
I'm using jdk1.8.0_333 / jre1.8.0_333. Do you know if this is a problem or not? Or I need to try to switch to a new version to be free? I'm not really going to make money from my first release, so I would like to try to keep it free.
Also I've seen that there is another source for Java: OpenJDK[^] / OpenJDK JDK 184.108.40.206 GA Release[^]. Is this one free, while the one from Oracle you need a subscription but contains some more advanced features/libraries?
Because this is a issue that can lead to financial/law problems I took a look at JDK's and I found Adoptium[^]. Do you know if this is free for commercial use? I see that they have JDK and JRE. I will try to contact them as well, but for sure it will take quite a long time before they respond.
Let's start by formatting the code and adding ;line numbers so it is actually readable. You can now clearly see that at the very least you have invalid lines at lines numbers 5 and 22. I assume these are supposed to be comment lines so require a "//" at the beginning. You also have mixed capitalisation on your setters and getters.
So start by fixing those and see what happens.
Hello. I'm new to Java -- I want to learn, and am going through HFJ. I know it's an old book, but there are no later editions, so I may be behind the times.
I'm not a professional programmer, but I'm on a few programming forums, and I can't seem to get an answer to a question I have regarding the Runnable interface. I'm in chap 15 of the book re: threading, and I came across this statement in regards to starting a new thread:
public class MyRunnable implements Runnable
Runnable threadJob = new MyRunnable ()
What I don't understand is how can you make a new object with an interface, but use the class MyRunnable. Shouldn't it be MyRunnable thread = new MyRunnable ()?
I'm just confused. Runnable isn't a class, so what's going on?
Any class can be "cast" to an interface that it implements; or it can be cast to any object it is "derived" from (e.g. "object").
In your example, a new MyRunnable is created and implicitly "down cast" to Runnable.
The interface acts like a proxy for all (different) classes that implement that interface; allowing only access to the properties / methods identified via the interface.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
In C++ terms, a Java interface is a pure abstract class that only has member functions. No fields.
Fields on interfaces are always “constants”. (This is an older Java rule)
It is closer to the COM interface concept.
It could also be called an API contract.
An object can implement multiple interfaces.
This is an easy way to create delayed binding. The thread library was written decades ago, but you can create an Object today that will be usable by this old library as long as you honor the contract defined by the library. For Runnable, you must provide the run() method. The live Thread object will then invoke your run() method when you get your plumbing code correct.
Hash tables provide a mechanism by which you can create indexed tables in which the index is a value other than a string. Implement and test an integer key Open Address Hash table. Implement the following interface. • String get(int k); • void put(int k, String v); • bool contains(int k); • void delete(int k); • void printHash(); You must provide an interactive or command-line test application for the hash table. Make the hash table 31 entries, and make sure at least one collision occurs in your data input. You must delete some data from your table to demonstrate deletion. (100 points)
Notable to get output. Could you please anyone help me on this