Results 1 to 5 of 5

Thread: Dot Syntax

  1. #1
    jdodle is offline Member
    Join Date
    Oct 2013
    Posts
    11
    Rep Power
    0

    Default Dot Syntax

    When using dot syntax you might have something like char.compareCharacter(argument) and lets say the argument is another char. I know how to retrieve the arguments data, but how do you get the data from char?

    Thanks in advance.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Dot Syntax

    how do you get the data from char?
    char (an illegal name for a variable: char is a primitive data type) I'll refer to it as aChar.
    If aChar is a reference to an instance of a class, you need to read the API doc for that class to see what methods it has that can be called to get the data it contains. For example:
    someData = aChar.getSomeData();
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jdodle is offline Member
    Join Date
    Oct 2013
    Posts
    11
    Rep Power
    0

    Default Re: Dot Syntax

    Ok,

    first: I know it was an illegal name, I was using it to imply the data type I wanted to compare.

    second: I am still confused and probably because I used a bad example, so I will use my specific example.

    I have a class called Virus and I have a client method that creates several Virus objects. within this same method I want to check if some of the contents of the objects are the same and to do this I am overriding the equals method but within the Virus class. So I want to call the equals method in the form of object1.equals(object2). I know how to get the data from object2 but how do I get the data from object1?

  4. #4
    jdodle is offline Member
    Join Date
    Oct 2013
    Posts
    11
    Rep Power
    0

    Default Re: Dot Syntax

    Ok I figured it out

    Thank you for your help Norm!

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Dot Syntax

    In you example: object1.equals(object2)
    object1 is the instance of the class whose equals() method is being called. All the values in the instance are available in the method.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Syntax Errors
    By andimiami in forum New To Java
    Replies: 8
    Last Post: 09-15-2011, 02:23 PM
  2. Quotations Syntax Help
    By loopsnhoops in forum New To Java
    Replies: 2
    Last Post: 06-12-2011, 08:44 AM
  3. Syntax correct?
    By dbashby in forum New To Java
    Replies: 5
    Last Post: 09-22-2009, 07:44 AM
  4. A question about syntax.
    By mr_o in forum New To Java
    Replies: 2
    Last Post: 09-19-2009, 09:30 PM
  5. syntax error
    By gabriel in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 04:26 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
  •