Results 1 to 4 of 4
  1. #1
    victorkeath is offline Member
    Join Date
    Nov 2008
    Posts
    1
    Rep Power
    0

    Lightbulb getting identifier expected error . help me !

    hi,
    this is small program of adding two integers and storing in other integer.the program is not compiling .

    public class additions{

    private int a =5;

    private int b=6 ;

    private int c=9;

    public void add(intm ,intn ) {

    a=m;

    b=n;

    c=a+b;

    System.out.println("value of summation is " +c);

    }

    public static void main(String []arg){

    additions objadd = new additions() ;

    objadd.add(7,8);

    System.out.println("value of a before declared is.. " +objadd.a);

    System.out.println("value of b before declared is .." +objadd.b);

    System.out.println("value of c before declared is .." +objadd.c);

    objadd.add(7,8);

    System.out.println("final summtion result is " + objadd.c);

    }

    }



    where is the error? tell me

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,307
    Rep Power
    25

    Default

    You forgot to post the full text of the error message. What was the referenced line number for example?

    It sounds like you have missing pairs for {}, [] or ().
    Check that they are all paired in your code.

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default list of errors..

    • the intm & intn arguments in the add method are not identified (they should be int)
    • In the add method, variables m & n don't exist... they should be replaced with variables intm & intn.

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes, it's all about this line as CJSLMAN says.

    Java Code:
    public void add(intm ,intn ) {
    Did you read carefully that error message you get? Most probably that error message should pointed this error.

Similar Threads

  1. Identifier expected error
    By vasu18 in forum New To Java
    Replies: 1
    Last Post: 01-01-2008, 05:49 PM
  2. Error: ')' expected
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:32 AM
  3. Error: <identifier> expected
    By barney in forum AWT / Swing
    Replies: 2
    Last Post: 07-31-2007, 07:38 AM
  4. Error: '{' expected
    By romina in forum New To Java
    Replies: 1
    Last Post: 07-26-2007, 09:34 AM
  5. MSG ERROR: : expected
    By Marty in forum New To Java
    Replies: 1
    Last Post: 05-31-2007, 02:21 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
  •