There seems to be a difference between main(String[] args)
and other string arrays that i can not figure out, my example.
public class TestArgs
{
public static void main(String[] args) {
String[] x = {"1","2","3"};
System.out.print( x[2] == "3" );
System.out.print( args[2] == "3" );
}}
I run this program as:
java TestArgs 1 2 3
I would expect the output to be "truetrue" but instead I get "truefalse"
Could someone please tell me what the difference is, or am I just doing something really stupid...
in java, you have to use "test".equals("test")
to test for string-equality ;)
strings are objects and the objects are not the SAME, they just have the same VALUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With