Search:

Type: Posts; User: jps

Search: Search took 0.10 seconds.

  1. Replies
    15
    Views
    1,441

    Re: primitive vs reference data-type

    This is an optimization any decent compiler should make, yes, but there is no guarantee it will happen that I know of.
  2. Replies
    15
    Views
    1,441

    Re: primitive vs reference data-type

    The compiler has optimized because s1 and s2 were declared with static strings of equal value, and since strings are immutable there was no reason to make two different String objects with the same...
  3. Replies
    15
    Views
    1,441

    Re: primitive vs reference data-type

    s1 and s2 would refer to two different objects which happen to hold the same value, but s1==s2 is false, they are two different objects
  4. Replies
    15
    Views
    1,441

    Re: primitive vs reference data-type

    Some code to play with
    public class EditableObject {

    private String message;

    public EditableObject(String message) {
    this.setMessage(message);
    }

    public String getMessage() {
  5. Replies
    15
    Views
    1,441

    Re: primitive vs reference data-type

    Strings are immutable, so:
    a = "before";
    b = a; (now they both point to the same string)

    a = "after" (now a points to a different string and b still points to the same old string because b was...
Results 1 to 5 of 5