<identifier> expected error in Java

Discussion in 'Software' started by mdgtjulie, Feb 6, 2014.

  1. mdgtjulie

    mdgtjulie

    Joined:
    Feb 6, 2014
    Messages:
    1
    I'm trying to create a square class that extends Rectangle. I want to set square width equal to square height. I keep getting an identifier expected error. Here is my code:

    public class Square extends Rectangle
    {
    //Declarations
    private double squareWidth = width;
    private double squareHeight = height;

    public double getSquareWidth()
    {
    return squareWidth;
    }

    public Square mySquare = new Square();
    mySquare.getSquareWidth() = squareHeight;
    }

    mySquare.getSquareWidth() = squareHeight is the line giving me trouble. (As I understand it, since I declared my variables, I can now use them anywhere in the program. I'm not understanding why I'm getting this error.)
    mdgtjulie, Feb 6, 2014
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rinka_s
    Replies:
    0
    Views:
    868
    rinka_s
    Apr 29, 2007
  2. msnider9

    help with Java <identifier> expected

    msnider9, Apr 13, 2008, in forum: General Computer Support
    Replies:
    0
    Views:
    2,619
    msnider9
    Apr 13, 2008
  3. Tcole90

    JAVA < identifier > expected error

    Tcole90, Mar 29, 2010, in forum: General Computer Support
    Replies:
    0
    Views:
    4,366
    Tcole90
    Mar 29, 2010
  4. Zuni

    Error: <identifier> expected

    Zuni, Nov 14, 2011, in forum: Software
    Replies:
    0
    Views:
    1,567
  5. Keke101

    <identifier> expected

    Keke101, Jan 2, 2012, in forum: The Lounge
    Replies:
    2
    Views:
    4,302
    sandi7777777
    Oct 11, 2012
Loading...

Share This Page