Results 1 to 3 of 3
  1. #1
    san1 is offline Member
    Join Date
    Feb 2014
    Posts
    9
    Rep Power
    0

    Default <identifier> expected error

    I'm getting an "identifier expected" error for the following code for comparing 2 wallets and printing each pair of banknotes. Here's the code. Thanks for your help:


    public void printBankNotePairs(Wallet other)
    {
    StringBuffer myBuffer = new StringBuffer("Pairs: ");

    for(int i = 0; i < count; i++)
    {
    for(int j = 0 + i; j < other.length; j++)
    {
    if( this.contents[i] == other.[j]){
    myBuffer.append(" " + contents[i]) );
    i++;

    }

    }

    }

    System.out.println(myBuffer.toString());

    }

    }

    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default Re: <identifier> expected error

    Quote Originally Posted by san1 View Post
    I'm getting an "identifier expected" error for the following code for comparing 2 wallets and printing each pair of banknotes. Here's the code. Thanks for your help:

    Java Code:
    if( this.contents[i] == other.[j]){
    What is 'other.' supposed to mean? The compiler expects a member of the 'other' object; hence the error message. b.t.w. stick your code between [code] ... [/code] tags for readability reasons.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    san1 is offline Member
    Join Date
    Feb 2014
    Posts
    9
    Rep Power
    0

    Default Re: <identifier> expected error

    Fixed. It appears I didn't complete the expression:

    if(contents[i] != other.contents[i])

    Thanks for your help...

Similar Threads

  1. error: <identifier> expected
    By madnbri in forum New To Java
    Replies: 7
    Last Post: 02-19-2014, 09:22 PM
  2. <identifier expected> error
    By jacjacjac in forum New To Java
    Replies: 5
    Last Post: 10-14-2012, 02:39 AM
  3. <identifier expected> error. please help!
    By christopherx in forum AWT / Swing
    Replies: 9
    Last Post: 10-02-2011, 10:23 PM
  4. getting identifier expected error . help me !
    By victorkeath in forum New To Java
    Replies: 3
    Last Post: 11-07-2008, 05:49 PM
  5. Error: <identifier> expected
    By barney in forum AWT / Swing
    Replies: 2
    Last Post: 07-31-2007, 07:38 AM

Posting Permissions

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