Resolving “The method must return a result of type int” in Java

后端 未结 9 666
庸人自扰
庸人自扰 2021-01-21 12:37

I\'m very new to Java. Eclipse is giving me the error

The method must return a result of type int

for the following code:



        
9条回答
  •  一向
    一向 (楼主)
    2021-01-21 13:15

    Are you trying to put multiple classes into one file? Each class should get its own .java file with the appropriate name. Also make the first letter of your class upper case, as this is the naming convention.

    As an aside, your function will only work if a is larger than c. You've missed out on some cases.

    EDIT: you can have nested classes, but I think you might want to stay away from stuff like that for now.

提交回复
热议问题