Though both are used for comparison, but the way they both works are pretty much different.
== is called the comparison operator. This compares the references of the operands, that is the physical address in which the variables are stored. It returns true if and only if both variables refer to the same object.
String.equals() is a pre-built function of String class which compares the values stored in the objects. It checks nothing except for the value specified in the function.
Thus in your code when you are using == it is comparing the reference of userId and u_id whereas when using equals() it is comparing the values stored in them.