Same Char then return 0
(firstchar<second char) then return -1
(Second char> First char) then return 1.
Program:
public class A
{
public static int test(char c1, char c2)
{
if(c1<c2)
return -1;
else if(c1>c2)
return 1;
else
return 0;
}
public static void main(String[] args)
{
System.out.println(test('N','A'));
}
}
(firstchar<second char) then return -1
(Second char> First char) then return 1.
Program:
public class A
{
public static int test(char c1, char c2)
{
if(c1<c2)
return -1;
else if(c1>c2)
return 1;
else
return 0;
}
public static void main(String[] args)
{
System.out.println(test('N','A'));
}
}
0 comments:
Post a Comment