![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2005
Posts: 8
Rep Power: 0
![]() |
Coding problem. Help!!!
Hi
I've written some lines of codes but can't make it work. Can anyone help me and tell me what's the problem.
public class Point
{
public static void main(String args[])
{
Pointing point1= new Pointing(2,3);
Pointing point2= new Pointing(4,5);
point1.displayDetails();
point2.displayDetails();
}
class Pointing
{
Pointing(int XCoord, int YCoord)
{
this.XCoord=XCoord;
this.YCoord=YCoord;
displayDetails()
{
System.out.println("(" + XCoord + "," + YCoord + ")");
}
}
}
} |
|
|
|
|
|
#2 |
|
Programmer
|
Two problems that I can see:
public class Point
{
public static void main(String args[])
{
Pointing point1= new Pointing(2,3);
Pointing point2= new Pointing(4,5);
point1.displayDetails();
point2.displayDetails();
}
class Pointing
{
private int XCoord = 0;
private int YCoord = 0;
Pointing(int XCoord, int YCoord)
{
this.XCoord=XCoord;
this.YCoord=YCoord;
void displayDetails()
{
System.out.println("(" + XCoord + "," + YCoord + ")");
}
}
}
}Last edited by kirkl_uk; May 21st, 2005 at 2:45 PM. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: May 2005
Posts: 8
Rep Power: 0
![]() |
Thanks a lot kirkl_uk!!!
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: May 2005
Posts: 8
Rep Power: 0
![]() |
I've tried it but it still doesn't work. It's about a ; about line 25 but i can't see where there is a ; missing.
|
|
|
|
|
|
#5 |
|
Programmer
|
displayDetails() cant be inside of the constructor Pointing...
public class Point
{
public static void main(String args[])
{
Pointing point1= new Pointing(2,3);
Pointing point2= new Pointing(4,5);
point1.displayDetails();
point2.displayDetails();
}
}class Pointing
{
private int XCoord = 0;
private int YCoord = 0;
Pointing(int XCoord, int YCoord)
{
this.XCoord=XCoord;
this.YCoord=YCoord;
}
public void displayDetails()
{
System.out.println("(" + XCoord + "," + YCoord + ")");
}
}JD |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|