Question 63 : Write a program in Java to find the absolute value of an integer.
Java Program :
class absolute
{
static void cal(int a)
{
int b=a>0?a:-a;
System.out.print("The absolute value of '"+a+"' : "+b);
}
}
Java Program :
class absolute
{
static void cal(int a)
{
int b=a>0?a:-a;
System.out.print("The absolute value of '"+a+"' : "+b);
}
}
Math.abs() would do the same work for you.
ReplyDeleteNice Example ... visit more java examples
ReplyDeleteWell explained string operation .
ReplyDeletethere are good String program collection visit More Java Example