Java 为什么我总是犯这个错误;错误:意外类型";

Java 为什么我总是犯这个错误;错误:意外类型";,java,oop,compiler-errors,Java,Oop,Compiler Errors,我在编译这段代码时遇到了同样的错误。我想知道如何成功地添加租赁天数和租赁费率。请帮忙 Tractor.java:83: error: unexpected type RentalDays + RentalRate = RentalProfit; ^ required: variable found value 1 error 代码: import java.util.*; 公营拖拉机 { 私有字符串名称; 私家车; 私人租金;

我在编译这段代码时遇到了同样的错误。我想知道如何成功地添加租赁天数和租赁费率。请帮忙

 Tractor.java:83: error: unexpected type
         RentalDays + RentalRate = RentalProfit;
                    ^
 required: variable
  found value
1 error
代码:

import java.util.*;
公营拖拉机
{
私有字符串名称;
私家车;
私人租金;
私人国际租赁日;
公共国际租赁费率(国际租赁费率)
{
如果(租金100000)
{
返回-1;
} 
其他的
{
退还此租金;
}
}
public int getRentalRate()
{
退还此租金;
}
公共国际租赁日(国际租赁日)
{
如果(租金365天)
{
返回-1;
} 
其他的
{
归还这个。租期;
}
}
公共int getRentalDays()
{
退还此租金;
}
公共国际租赁利润(国际租赁费率,国际租赁日)
{
国际租赁公司;
租金天数+租金率=租金利润;
}
}

只需编写要添加的代码即可

public int RentalProfit(int RentalRate, int RentalDays)
{
  return RentalDays + RentalRate;
}
RentalDays+RentalRate=RentalProfit
无效,因为
=
运算符的左手大小应该是要分配给的变量,而不是加法的结果。
你的意思是
RentalProfit=RentalDays+RentalRate

更改

int RentalProfit;

     RentalDays + RentalRate = RentalProfit;

int RentalProfit;

     RentalDays + RentalRate = RentalProfit;
    return RentalDays + RentalRate;