Results 1 to 6 of 6

Thread: Object Dereferencing. [resolved by VirtuallyVB]

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Object Dereferencing. [resolved by VirtuallyVB]

    Anybody know what that is? Im not too sure myself. The code below works great. But the code under it at compile time i get char cannot be dereferenced. what does that mean?

    Code:
       try {
        StringBuffer sb = new StringBuffer();
           for(int i = 0; i < c.length; ++i){
               sb.append(c[i]);
                jta.setText(new String(sb)); 
                 Thread.sleep(75); 
           }
        }catch(Exception e){System.err.println(e);}
    // cannot be derefrenced
    Code:
      String s = new String(c); 
        for(int i = 0; i < c.length; ++i){
            jta.setText(new String(s.charAt(i).toString()));
              Thread.sleep(75);   
        }

  2. #2
    VirtuallyVB
    Guest
    The primitive "char" datatype does not have the object method "toString()". Try jta.setText(String.valueOf(s.charAt(i)));

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    By VirtuallyVB
    The primitive "char" datatype does not have the method "toString()".
    Now that i understand.

    Yes this works now too! Thanks....
    jta.setText(String.valueOf(s.charAt(i)));

  4. #4
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332

    Exclamation What is Object Dereferencing?

    this is all nice but you still haven't explained object deferencing is.
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  5. #5
    VirtuallyVB
    Guest
    I think Dil may have a better definition of "object dereferencing" at the ready since he used the term.

    I don't see the difference between referencing and dereferencing. I think I first heard the term in C when trying to get at the value pointed at by a C pointer. In Object-Orientation, it may be safe to think of it as a "handle" or "reference to the object" by which we can address its members (When I say "member", I mean variable OR method). Perhaps we "dereference" when we "use the reference" in this object member addressing scheme. -- confirm this before using it as an exam answer.

    So, since Dil didn't have an object (since he had a primitive "char"), he could not possibly "dereference an object". char did not reference (or is that "dereference") any members (as objects do).

    Hope that helps Cap'.

  6. #6

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Sorry, i just got back from Florida today. I looked for some places in Disney world that maybe had a computer so i could post on VB World, but i had no luck. I look up the term and VirtuallyVB basicly summed that one up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width