Skip to content

Tag: java

what databases can be used with java?

I am doing an undergrad final project, and need to justify my choice of MySQL for the database element of my project. Truth is, it’s the only one I can really use, and hence I went for it. What other database systems could I have used? Any advantages and disadvantages of these over MySQL? Answer In fact…

Compute hex color code for an arbitrary string

Heading Is there a way to map an arbitrary string to a HEX COLOR code. I tried to compute the HEX number for string using string hashcode. Now I need to convert this hex number to six digits which are in HEX color code range. Any suggestions ? Answer If you don’t really care about the “meaning&#82…

How to create own filetype?

I want to create own filetype to save objects in my app. Basically, I urgently do not need new filetype, but it will be better. I have class. For example Car. It has constructor (String name, String color, int length, Driver driver). When a car is created (its instance), how to save it like a file? Answer To …

Overload with different return type in Java?

Why is it not possible to overload a function just by changing the return type? Will that change in a future version of Java? By the way, just for reference, is this possible in C++? Answer You can’t do it in Java, and you can’t do it in C++. The rationale is that the return value alone is not suf…

How can I do LZW decoding in Java?

I have a database which contains picture data stored as a binary blob. The documentation says the data is encoded using LZW. I thought that I could decode it using the Zip or GZip input streams found in the Java library, but it didn’t work – I got an exception that said the format of the data is n…

Java – ImageIcon won’t show image

I’m trying to load the icon but it won’t show up. The jpanel is within a boxlayout. I don’t know if that messes things up. It’s strange because I can add pretty much anything else except icon images. I went through the debugger and searchIcon is showing the width and height to be -1. D…