Hello.
I think there are many mistakes on your code.
1. You have to declare your class "point" with a first-letter
uppercase as
class Point {
... //Define the class here
}
2. Since you have declared a "point" class, you don't have to add a
return type to point as method, because a method which has the same
name as the its class is a constructor. Then, you'll have
Point(int a, int b) {
... //Your code here
}
3. It isn't a good thing to use a method named print() as you did,
because it's a reserved method's name of Java core package System.out
@+
On 2 fév, 10:00, 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("-------------------------------");
> }
>
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---