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

How do I print my Java object without getting “SomeType@2f92e0f4”?

Background All Java objects have a toString() method, which is invoked when you try to print the object. This method is defined in the Object class (the superclass of all Java objects). The Object.toString() method returns a fairly ugly looking string, composed of the name of the class, an @ symbol and the hashcode of the object in hexadecimal. The code for this looks like: … Read more

Is string::compare reliable to determine alphabetical order?

According to the docs at cplusplus.com, The member function returns 0 if all the characters in the compared contents compare equal, a negative value if the first character that does not match compares to less in the object than in the comparing string, and a positive value in the opposite case. So it will sort … Read more

AttributeError: ‘str’ object has no attribute ‘items’

You are passing in a string; headers can’t ever be a JSON encoded string, it is always a Python dictionary. The print results are deceptive; JSON encoded objects look a lot like Python dictionary representations but they are far from the same thing. The requests API clearly states that headers must be a dictionary: headers – (optional) Dictionary of HTTP Headers to send with the Request. JSON data is something you’d … Read more

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