Hi,

in the point class you make the constructor has return type void so
the program treated it as a method
as the constructor must not has areturn type

this is the correct code

public class Main
{
    public static void main(String[] args)
    {
      point p1 = new point(5,6);
      p1.print();
    }

}
class point
{
    private int x=0;
    private int y=0;

    point(int a,int b)
    {

        this.x=a;
        this.y=b;
    }

    void print()
    {
        System.out.println("Value of x: "+x+ " Value of y:"+y);
        System.out.println("-------------------------------");
    }
}



On 2/2/09, prasad jedhe <[email protected]> wrote:
>>> i have written this code & am getting an error at line 5 as *"cannot find
> symbol ;symbol :constructor point(int,int )"*
>
> public class Main                                //line 1
> {                                                        //line 2
>     public static void main(String[] args) //line 3
>     {                                                   //line 4
>       point p1 = new point(5,6);             //line 5<< giving error at this
> line
>       p1.print();
>     }
>
> }
> class point
> {
>     private int x=0;
>     private int y=0;
> void point(int a,int b)
>     {
>
>         this.x=a;
>         this.y=b;
>     }
>     void print()
>     {
>         System.out.println("Value of x: "+x+ " Value of y:"+y);
>         System.out.println("-------------------------------");
>     }
> }
>
> >
>


-- 
A.S.El-Dalatony

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to