Results 1 to 3 of 3

Thread: Object Dereferencing?

  1. #1

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

    Object Dereferencing?

    I posted this in the Java forum since it is Java code but i think have a better chance of getting this answered here.

    The code below works great. But the code under it at compile time i get char cannot be derefrenced. 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);}

    Code:
    // cannot be derefrenced 
      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
    amac
    Guest
    One question... what is c defined as?

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    c is defined as a char[] array.

    f = new File("C:\\Java\\TTHelp.txt");
    char[] c = new char[(int)f.length()];


    I think the problem is that in the code below
    Code:
    // cannot be derefrenced 
      String s = new String(c); 
        for(int i = 0; i < c.length; ++i){
            jta.setText(new String(s.charAt(i).toString()));
              Thread.sleep(75);   
        }
    I am creating a String Object from a char[] array. And somehow refering to the String is causing a problem.

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