No, jussij is right. It is your code which is not equivalent.
Your Java code is checking reference equality while the C# code is checking string value equality. The == operator works differently between strings in C# compared to Java. The only reason the Java code you wrote might "work" is due to Java interning strings so the references could be the same.
Your Java code is checking reference equality while the C# code is checking string value equality. The == operator works differently between strings in C# compared to Java. The only reason the Java code you wrote might "work" is due to Java interning strings so the references could be the same.