Your class name have the same name Point. Rename the class:
/**
* Project Name: project2
* Package Name:
* File Name: Point1.java
* Created Time: 3:55:52 PM Feb 2, 2009
* Author: [email protected]
*/
public class *Point1 *{
public int x=0, y=0;
public Point1(int x, int y) {
this.x=x;
this.y=y;
System.out.println("x: " + x);
System.out.println("y: " + y);
}
public static void main(String[] args) {
new Point1(2, 3);
}
}
*Result: *
x: 2
y: 3
Contact to:
[email protected]
On Mon, Feb 2, 2009 at 14:22, Andi Zunaidi <[email protected]> wrote:
>
> > i am unable to do*' this'* keyword can you any one explain this .
>
> I think "this" keyword is talking about the scope of variable.it's
> meaning that you call "this" keyword on the same class as constructor
> ex:
>
> public class *Point *{
> public int x = 0;
> public int y = 0;
>
> //constructor
> public Point(int x, int y) {
> this.x = x;
> this.y = y;
> }
> }
>
> regard's
>
> Andi
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---