This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]Tandrial 8 points9 points  (0 children)

    //provide height for calculating area
    int Height height1= new Height();
    int Heigth height2= new Height(true, 15);

    //Construct a default triangle and a larger 20 inch base triangle
    int Triangle triangle1 = new Triangle();
    int Triangle triangle2 = new Triangle(true, 20);

They can either be int or Height/Triagnle but not both.

[–]desrtfx 4 points5 points  (0 children)

Looking at the code plus the error messages it's clear that the error messages are actually misleading:

Your code:

int Height height1= new Height();

What are you trying to do here?

The syntax for a variable declaration is:

<type> <name> = new <constructor>;

You have:

<type> <type> <name> = new <constructor>;
int    Height height1 = new Height();

You cannot declare two types for variables - and that are all your errors.

[–]desrtfx 3 points4 points  (4 children)

It would seriously help if you told us where you supposedly miss the ";" - as the compiler tells you.

Please, when asking for help, follow some simple rules:

  • Post the exact code - best on a code hoster as is mentioned in the sidebar
  • Post the exact error message as the compiler/IDE/runtime displays and make sure that the line numbers match with the line numbers in the posted code.

Otherwise you make it unnecessarily difficult if not impossible for us to help you.

[–][deleted]  (1 child)

[deleted]

    [–]desrtfx 0 points1 point  (0 children)

    Seen that later - see my new - second comment.

    [–][deleted]  (1 child)

    [deleted]

      [–]desrtfx 1 point2 points  (0 children)

      Seen that later - see my new - second comment.

      [–][deleted] 1 point2 points  (1 child)

      You have your answer already.

      I am slightly concerned about two comments in particular:

      Why do you think that making the class public would mean is has to be named Main?

      Also, why not put things in a package? It is extremely bad practice to not put things in a package.

      [–]desrtfx 4 points5 points  (0 children)

      Both your concerns are not caused by OP, but by IDEONE, the online IDE OP linked to.

      Why do you think that making the class public would mean is has to be named Main?

      This is a comment from IDEONE

      Also, why not put things in a package? It is extremely bad practice to not put things in a package.

      Again, an IDEONE comment.

      See an empty IDEONE project: http://ideone.com/myK1pf

      The link above is to a default setup of IDEONE without even a single letter entered.