Wednesday, 21 May 2014

Java code for Character arguments with return type is Integer.

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'));

}

}
  

0 comments: