0

I have just started taking Java as a course in college and I am having a problem understanding how to find the syntax errors in a definition for a class.I am not asking for answers I just need help understanding it more.

The class is


public class AA
{

private int x;
private int y;

public void print()
{

System.out.println(x + " " +y);
}
public int sum ()
{
return x + y;

}

public AA ()
{
x = 0;
y = 0;
}

public int AA(int a, int b)
{

x = a;
y = b;

}
}

please help it is very urgent that i understand this.

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by javanew
0

Are you getting a syntax error? What is the error? We can't help you understand the errors if we don't know what they are.

Please post you code in code tags next time.

0

Are you trying to overload your constructor logic with public int AA(int a, int b)? If so you do not need the int as this specifies a return type. However, if you are not trying to overload the contstructor you need to return an integer from that method. alternativly change it to void, this may cause errors anyway due to having a method named the same as your class. Let me know the purpose of your final method please.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.