Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sum of two numbers

843785Mar 20 2009 — edited Mar 20 2009
hi,
i wrote the java programme to add two numbers as a userinterface when iam compile it iam getting two errors.which are like this " constructor Sum(java.lang.String)"where iam going wrong could you tell me please.
my prog. is like this.

class Sum
{
int a,b,c;
void add(int x,int y)
{
a=x;
b=y;
c=x+y;
System.out.println("The sum of"+x+"&"+y+"is "+c);
}
}
class SumDemo
{
public static void main(String[] args)
{
if(args.length==0)
{
System.out.println("Plz Pass the Data");
}
else
{
Sum so=new Sum(args);
int x=Integer.parseInt(args[0]);
int y=Integer.parseInt(args[1]);
so.add(x,y);
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2009
Added on Mar 20 2009
11 comments
673 views