What is a hash function in java?

The Wikipedia article will have a lot of technical information, but a simplistic view of hashing is something like the following. Imagine that there’s a magical function that can give a number to any object. Given the same object, it always return the same number. Immediately now you have a quick way to test if … Read more

.class vs .java

A .class file is a compiled .java file. .java is all text and is human readable..class is binary (usually). You compile a java file into a class file by going to the command line, navigating to the .java file, and running You must have a java SDK installed on your computer (get it from Oracle), and … Read more

Dice Rolling java program

You should use a while loop: The dice are rolled again and again until the player has won or lost (then, break ends the while loop).

How to use the command update-alternatives –config java

You will notice a big change when selecting options if you type in “java -version” after doing so. So if you run update-alternatives –config java and select option 3, you will be using the Sun implementation.Also, with regards to auto vs manual mode, making a selection should take it out of auto mode per this page stating: When using the –config option, alternatives will list all of the choices … Read more

difference between equals() and hashCode()

The equals() and hashCode() methods prove to be very important, when objects implementing these two methods are added to collections. If implemented incorrectly it might screwed up your life. equals() : This method checks if some other object passed to it as an argument is equal the object in which this method is invoked. It is easy to implement the … Read more

In Java, how to assign the variable number=Integer.parseInt(args[0]) a value if no argument is passed?

You could assign value of n as 0 or any other value by default and use if(args.length > 0) { to check whether any arguments is given. Below is full example with comments: Note: Users which are not so familiar with java, this program can be run by: Saving it to Infinity.java Compiling it with cmd or terminal by writing: javac Infinity.java Executing it … Read more

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