Results 1 to 2 of 2
  1. #1
    paul is offline Member
    Join Date
    Jul 2007
    Posts
    26
    Rep Power
    0

    Default Error: Non-static method append(char) cannot be referenced from a static context

    I'm having trouble trying to use StringBuffer() on the following code. The error I'm getting is:
    ChangeBase.java:91: non-static method append(char) cannot be referenced from a static context.

    Java Code:
    public void actionPerformed(ActionEvent e)
    {
    //....
        for(int j = 0; j<count; j++){ 
            test = ChangeBase.pop();
            System.out.println(test);
            StringBuffer.append(str.charAt(test));//where str is just a string. This is line 91.
         }
     }
    StringBuffer buf = new StringBuffer();
    jtfResult.setText(buf.toString());
     //...
    Anyone has an idea what the error is refering to? Thanks

  2. #2
    coco is offline Member
    Join Date
    Jul 2007
    Posts
    39
    Rep Power
    0

    Default

    You need to create an instance of the StringBuffer, as you are here:
    Java Code:
    StringBuffer buf = new StringBuffer();
    Greetings.

Similar Threads

  1. Replies: 3
    Last Post: 03-20-2009, 01:35 AM
  2. Replies: 0
    Last Post: 04-17-2008, 12:07 AM
  3. Help with code (static error)
    By oceansdepth in forum New To Java
    Replies: 1
    Last Post: 03-28-2008, 05:32 AM
  4. is overriding static method possible
    By raghu in forum Advanced Java
    Replies: 1
    Last Post: 01-22-2008, 01:38 AM
  5. Replies: 1
    Last Post: 08-01-2007, 10:25 PM

Posting Permissions

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