简体   繁体   中英

How do I determine a Java method return type from parameters?

I need an explanation. When no method header is given, how would I know what return type the method would give from context clues?

for example:

int someNum = someWord.someMethod();

I'm a beginner, sorry if this is a dumb question.

If you are asking about someMethod() the the return value is assigned to an int variable, so the return type is int . The method signature will look like this

public int someMethod() {
}

The return type is not necessarily int , it is any type that is assignment compatible with int .

In addition to int , it could also be Integer , byte , Byte , short , Short , char , or Character .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM