## Java == (double equals) vs. equals method

###### Java == (double equals) vs. equals method:

The double equals sign == compares references while equals compares values for equality. See this and this for more.

##### Code:

Here both of the string literal point to the same object in the String Constant Pool so their comparison value is true,

String a = "abc";
String b = "abc";

if(a == b){
System.out.println("Match");
}else{
System.out.println("Mismatch");
}


But this comparison false,

String e = new String("a");
String f = new String("a");

if(e == f){
System.out.println("Match");
}else{
System.out.println("Mismatch");
}


Here two new String objects are created. Then their reference is compared to see if they point to same object. Since they points two distinct objects in the heap the value returned in false. So the output is “Mismatch”.

## Vector Calculus: Finding out divergence and curl of vector field

Vector Calculus – Finding out divergence and curl of vector field:

In case of fluid flow,

Divergence:  Relates to the Way in which fluid flows away
or, toward from a point.
It has Scaler values.

Curl:        Rotational properties of a fluid at a point.
It has vector values.


Vector field in 3 space with xyz co-ordinate system, $\overrightarrow{F}(x,y,z) = < f(x,y,z), g(x,y,z), h(x,y,z) >$

Then divergence of function $\overrightarrow{F} (x, y, z)$ is, $div \vec{F} = \nabla . \vec{F} = < \frac{\delta}{\delta x}, \frac{\delta}{\delta y}, \frac{\delta}{\delta z} > . < f, g, h >$ $div \vec{F} = \frac{\delta f}{\delta x} + \frac{\delta g}{\delta y} + \frac{\delta h}{\delta z}$

The curl of the function $\vec{F} (x, y, z)$ is, $curl \vec{F} = \nabla \times \vec{F}$ $= \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ \frac{\delta}{\delta x} & \frac{\delta}{\delta y} & \frac{\delta}{\delta z} \\ f & g & h \end{vmatrix}$ $curl \vec{F} = < \frac{\delta h}{\delta y} - \frac{\delta g}{\delta z}, \frac{\delta f}{\delta z} - \frac{\delta h}{\delta x}, \frac{\delta g}{\delta x} - \frac{\delta f}{\delta y} >$

#### Example: $curl \vec{F} = < x^2y, 2y^3z, 3z >$

Here, $f(x,y,z) = x^2y \\ f(x,y,z) = 2y^3z \\ f(x,y,z) = 3z$

We know divergence function, $div \vec{F} = \frac{\delta f}{\delta x} + \frac{\delta g}{\delta y} + \frac{\delta h}{\delta z} \ \ \ \ \ (1)$

Now, $\frac{\delta f}{\delta x} = \frac{\delta}{\delta x} x^2y = 2xy \\ \\ \frac{\delta g}{\delta y} = \frac{\delta}{\delta y} 2y^3z = 6y^2z \\ \\ \frac{\delta h}{\delta z} = \frac{\delta}{\delta z} 3z = 3$

So, from $eqn(1)$ we get, $div \vec{F} = 2xy + 6y^2z + 3$

Also, The curl of the function, $curl \vec{F} = \nabla \times \vec{F}$ $= \begin{vmatrix} \hat{k} & \hat{k} & \hat{k} \\ \frac{\delta}{\delta x} & \frac{\delta}{\delta y} & \frac{\delta}{\delta z} \\ f & g & h \end{vmatrix}$ $curl \vec{F} = < \frac{\delta h}{\delta y} - \frac{\delta g}{\delta z}, \frac{\delta f}{\delta z} - \frac{\delta h}{\delta x}, \frac{\delta g}{\delta x} - \frac{\delta f}{\delta y} > \ \ \ \ \ (2)$

calculating partial derivatives, $\frac{\delta h}{\delta y} = \frac{\delta}{\delta y} 3z = 0 \\ \\ \frac{\delta g}{\delta z} = \frac{\delta}{\delta z} 2y^3z = 2y^3 \\ \\ \frac{\delta f}{\delta z} = \frac{\delta}{\delta z} x^2y = 0 \\ \\ \frac{\delta h}{\delta x} = \frac{\delta}{\delta x} 3z = 0 \\ \\ \frac{\delta g}{\delta x} = \frac{\delta}{\delta x} 2y^3z = 0 \\ \\ \frac{\delta f}{\delta y} = \frac{\delta}{\delta y} x^2y = x^2$

So, from $eqn(2)$ we write, $curl \vec{F} = < 0 - 2y^3, 0 - 0, 0 - x^2 > \\ \\ curl \vec{F} = < -2y^3, 0, - x^2 > \\ or, \\ curl \vec{F} = -2y^3 \hat{i} - x^2 \hat{k};$