How to write Java function that returns values of multiple data types?

后端 未结 11 1655
耶瑟儿~
耶瑟儿~ 2021-01-03 23:34

For example, I want to create a function that can return any number (negative, zero, or positive).

However, based on certain exceptions, I\'d like the function to re

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 23:56

    No, one return reference to a customer.

    You can write a response object that encapsulates a boolean and an int together and set the values according to your whim.

    But if I was a user I'd think your design was confusing.

提交回复
热议问题