Is String s = "foobar";
atomic?
Assigning a object-reference should be, but I'm no really sure.
Thanks.
Atomic Data Types XML schema has no concept of a character as a data type and a string is an atomic primitive type.
Strings are Reference/Complex Object Type Strings in Java fall under the category of Reference/Complex Object data types. They store a reference to the object rather than the object itself. When you assign a string variable to another variable, It actually copies the reference to the object but not the object itself.
Yes. All reference assignments are atomic in java.
Just note that a composite statement like String s = new String("foobar")
is not atomic, because it comprises of an object creation and then an assignment separately.
Also note that "assignments to long and double variables may not be atomic", from JLS-17.7
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