in java write a method that takes two char arguments and returns 0 if both arguments are equal. the method returns -1 if first argument is smaller than the second and 1 if second is smaller than the first
Answers
Answered by
4
public int main(char a, char b)
{
int va = Integer.parseInt(a);
int vb = Integer.parseInt(b);
if(va == vb){
return 0;
}
if(va < vb){
return -1;
}
if(vb < va){
return 1;
}
}
// You can reach me if you face any //problem :-)
{
int va = Integer.parseInt(a);
int vb = Integer.parseInt(b);
if(va == vb){
return 0;
}
if(va < vb){
return -1;
}
if(vb < va){
return 1;
}
}
// You can reach me if you face any //problem :-)
Similar questions