Hi Prasad
you have made mistake in constructor declaration.
Remeber constructor never returns anything not even void and
constructor should be accessible to other so you should always add
"public" access specifier in the beginning of constructor creation.
prasad jedhe 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)
the above constructor should be like this one........
public 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("-------------------------------");
> }
> }
Hope that helps......................
Manna
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---