method identifiers


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: method identifiers

  1. #1
    Danny dsara34114aol.com Guest

    method identifiers


    I have been learnig from abook "Java manual of Style " which has given me
    a good start in Java .However I hae hit a snag . In one example for calculate
    rectangle I have been getting a lot of error messages when compiling . Not
    at first , but when I add their example code to modify the applet .In it
    it has me add "public int CalculateRectangleArea(inta,intb)
    {
    int Area;
    Area=a+b;
    return Area;
    }//end of calculateRectangleArea() "
    This gives me am error when I compile "identifier expected " . I have
    no clue what it is asking for or how to change it to make it right .
    Any clues would be appreciated !!

  2. #2
    Kyle Gabhart Guest

    Re: method identifiers


    "Danny" dsara34114aol.com wrote:
    >
    >I have been learnig from abook "Java manual of Style " which has given me
    >a good start in Java .However I hae hit a snag . In one example for calculate
    >rectangle I have been getting a lot of error messages when compiling . Not
    >at first , but when I add their example code to modify the applet .In it
    >it has me add "public int CalculateRectangleArea(inta,intb)
    > {
    > int Area;
    > Area=a+b;
    > return Area;
    > }//end of calculateRectangleArea() "
    > This gives me am error when I compile "identifier expected " . I have
    >no clue what it is asking for or how to change it to make it right .
    >Any clues would be appreciated !!


    Danny,

    It's looks like the error is just the result of a typo. Try changing the
    method's signature to:

    public int CalculateRectangleArea( int a, int b )

    The "identifier expected" error is probably referring to the two method parameters
    'a' and 'b'. They need to be "identified" to the compiler as integers.
    Without this identification, the compiler does not know how to treat them.
    I hope this is helpful. Let me know if you are still having trouble.

    Happy Coding!

    Cordially,

    Kyle Gabhart
    DevX Java Pro

  3. #3
    Guest

    Re: method identifiers

    Make sure that there is a space between the parameter type and the parameter
    itself.

    Your example should look as follows:
    public int CalculateRectangleArea(int a, int b)
    {
    int Area;
    Area=a+b;
    return Area;
    }//end of calculateRectangleArea()


    <Danny dsara34114aol.com> wrote in message news:3a8f384b$1@news.devx.com...
    >
    > I have been learnig from abook "Java manual of Style " which has given me
    > a good start in Java .However I hae hit a snag . In one example for

    calculate
    > rectangle I have been getting a lot of error messages when compiling . Not
    > at first , but when I add their example code to modify the applet .In it
    > it has me add "public int CalculateRectangleArea(inta,intb)
    > {
    > int Area;
    > Area=a+b;
    > return Area;
    > }//end of calculateRectangleArea() "
    > This gives me am error when I compile "identifier expected " . I

    have
    > no clue what it is asking for or how to change it to make it right .
    > Any clues would be appreciated !!




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center