• Compile error: java: expected

    From kaverigojre@gmail.com@21:1/5 to All on Sun Mar 19 03:00:03 2017
    Create and call object inside main method

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fernandofernando998877@gmail.com@21:1/5 to All on Fri Jun 22 00:54:17 2018
    hello i immediately need help!!!
    i am trying to learn overloading and i am in 10 standard so please help me
    i am getting identifier expected error

    import jav.io.*;
    public class Overload
    {
    double r,side,l,b,AreaSquare,AreaCircle,AreaRectangle;
    public void area(side)//this the line where error occurs
    {
    side1=side;
    AreaSquare=side1*side1;
    System.out.println("AREA OF SQUARE="+Areasquare);
    }
    public void area(l,b)
    {
    l1=l;
    b1=b;
    AreaRectangle=l1*b1;
    System.out.println("AREA OF RECTENGLE="+AreaRectangle);
    }
    public void area(r)
    {
    r1=r;
    PI=3.14;
    AreaCircle=PI*r1*r1;
    System.out.println("AREA OF CIRCLE="+AreaCircle);
    }
    public static void main()throws IOException
    {
    BufferedReader in=new BufferedReader (new InputStreamReader(System.in));
    Overload obj=new Overload();
    System.out.println("ENTER THE SIDE OF SQUARE=");
    side1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE LENGTH OF RECTANGLE=");
    l1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE BREADTH OF RECTANGLE=");
    b1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE RADIUS OF CIRCLE=");
    r1=Double.parseDouble(in.readLine());
    obj.area(side);
    obj.area(l,b);
    obj.area(r);
    }
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jukka Lahtinen@21:1/5 to fernandofernando998877@gmail.com on Sat Jun 23 14:37:35 2018
    fernandofernando998877@gmail.com writes:

    hello i immediately need help!!!
    i am trying to learn overloading and i am in 10 standard so please help me
    i am getting identifier expected error

    There is usually also a line number in the compilation error message,
    pointing to a specific line in your code. See which line it points to.
    (The actual error may in some cases be somewhere before the line where
    the compiler realized something is wrong.)

    --
    Jukka Lahtinen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Sosman@21:1/5 to fernandofernando998877@gmail.com on Sat Jun 23 08:05:57 2018
    On 6/22/2018 3:54 AM, fernandofernando998877@gmail.com wrote:
    hello i immediately need help!!!
    i am trying to learn overloading and i am in 10 standard so please help me
    i am getting identifier expected error

    import jav.io.*;

    "jav"?

    public class Overload
    {
    double r,side,l,b,AreaSquare,AreaCircle,AreaRectangle;
    public void area(side)//this the line where error occurs

    You must tell Java what type `side' is: a `double', an `int',
    or whatever. Thus, for example,

    public void area(double side) // if `side' is a `double'

    {
    side1=side;

    Similarly, you must specify the type of `side1'. Java cannot
    just guess whether it should be a `double' or `float' or `long',
    you must write what you intend. (You've made the same omission
    several more times; I won't point them all out but will trust you
    to fix them yourself.)

    AreaSquare=side1*side1;
    System.out.println("AREA OF SQUARE="+Areasquare);
    }
    public void area(l,b)
    {
    l1=l;
    b1=b;
    AreaRectangle=l1*b1;
    System.out.println("AREA OF RECTENGLE="+AreaRectangle);
    }
    public void area(r)

    I anticipate trouble with this overload, because if you decide
    to make `r' a `double' and you have also made `side' a `double'
    above, then Java will have no way to distinguish the two methods:
    They will have identical parameter lists. (The names of parameters
    don't disambiguate, only their number and types matter.)

    {
    r1=r;
    PI=3.14;

    FYI, the predefined constant `Math.PI' is considerably more
    accurate.

    AreaCircle=PI*r1*r1;
    System.out.println("AREA OF CIRCLE="+AreaCircle);
    }
    public static void main()throws IOException
    {
    BufferedReader in=new BufferedReader (new InputStreamReader(System.in));
    Overload obj=new Overload();
    System.out.println("ENTER THE SIDE OF SQUARE=");
    side1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE LENGTH OF RECTANGLE=");
    l1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE BREADTH OF RECTANGLE=");
    b1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE RADIUS OF CIRCLE=");
    r1=Double.parseDouble(in.readLine());
    obj.area(side);
    obj.area(l,b);
    obj.area(r);
    }
    }



    --
    esosman@comcast-dot-net.invalid
    Nine hundred forty-two days to go.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fernandofernando998877@gmail.com@21:1/5 to Eric Sosman on Sat Jun 23 09:03:14 2018
    On Saturday, June 23, 2018 at 1:06:04 PM UTC+1, Eric Sosman wrote:
    On 6/22/2018 3:54 AM, fernandofernando998877@gmail.com wrote:
    hello i immediately need help!!!
    i am trying to learn overloading and i am in 10 standard so please help me i am getting identifier expected error

    import jav.io.*;

    "jav"?

    public class Overload
    {
    double r,side,l,b,AreaSquare,AreaCircle,AreaRectangle;
    public void area(side)//this the line where error occurs

    You must tell Java what type `side' is: a `double', an `int',
    or whatever. Thus, for example,

    public void area(double side) // if `side' is a `double'

    {
    side1=side;

    Similarly, you must specify the type of `side1'. Java cannot
    just guess whether it should be a `double' or `float' or `long',
    you must write what you intend. (You've made the same omission
    several more times; I won't point them all out but will trust you
    to fix them yourself.)

    AreaSquare=side1*side1;
    System.out.println("AREA OF SQUARE="+Areasquare);
    }
    public void area(l,b)
    {
    l1=l;
    b1=b;
    AreaRectangle=l1*b1;
    System.out.println("AREA OF RECTENGLE="+AreaRectangle);
    }
    public void area(r)

    I anticipate trouble with this overload, because if you decide
    to make `r' a `double' and you have also made `side' a `double'
    above, then Java will have no way to distinguish the two methods:
    They will have identical parameter lists. (The names of parameters
    don't disambiguate, only their number and types matter.)

    {
    r1=r;
    PI=3.14;

    FYI, the predefined constant `Math.PI' is considerably more
    accurate.

    AreaCircle=PI*r1*r1;
    System.out.println("AREA OF CIRCLE="+AreaCircle);
    }
    public static void main()throws IOException
    {
    BufferedReader in=new BufferedReader (new InputStreamReader(System.in));
    Overload obj=new Overload();
    System.out.println("ENTER THE SIDE OF SQUARE=");
    side1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE LENGTH OF RECTANGLE=");
    l1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE BREADTH OF RECTANGLE=");
    b1=Double.parseDouble(in.readLine());
    System.out.println("ENTER THE RADIUS OF CIRCLE=");
    r1=Double.parseDouble(in.readLine());
    obj.area(side);
    obj.area(l,b);
    obj.area(r);
    }
    }



    --
    esosman@comcast-dot-net.invalid
    Nine hundred forty-two days to go.

    thanks very much!!!
    my program is working!!!
    i will always be grateful to you!!!
    you helped me to improve!!!
    thanks!!! thanks!!!
    thanks!!!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)