方法等于搜索是否等于两个数字

method equals search if is equal two numbers or not

我想帮助我 this.I 应该创建一个方法 equals 来检查两个 objects.If 对象是否相等然后它将 return 为真,否则它将 return 错误。 对我来说我已经研究过这个但是我以前用不同的方式做了一个方法

public static boolean trueorfalse(int cars,int bikes){
   boolean y;
   if(get.car==get.bikes)
   {
    System.out.println("are equal");
    y=true;
   }
    else
   {
    System.err.println("arent equal");
    y=false;
   }
 return y;
}

现在方法等于:

public static boolean equal(int cars,int bikes){  //i change the name?
       if(get.car==get.bikes)   // may needs here equalsof() something like this? or is completely wrong i am.
       {
        System.out.println("are equal");
        y=true;
       }
        else
       {
        System.err.println("arent equal");
        y=false;
       }
     return y;
    }

如果你能帮我解决这个问题,我会很感激,因为我想我已经解决了,但我还没有 sure.Thanks,我想说这是我第一次来这里,我不知道是否因为是 "begginer" 级你帮不上忙。

我想说,你太接近了,无法纠正。
现在,它已修复!

public static boolean equal(int cars,int bikes{
if(car==bikes)
//since you are comparing two ints, you don't require any !
{
System.out.println("are equal");
y=true;
}
else
{
System.err.println("arent equal");
/*Preferably use System.out.println().Having an inequality as this cannot be 
attributed to error. It's okay if you stick to your view.There is no hard and fast rule either !*/ 
y=false;
}
return y;
}