<identifier> expected error in Java

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

  1. mdgtjulie

    mdgtjulie

    Joined:
    Feb 6, 2014
    Messages:
    1
    Likes Received:
    0
    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. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.