Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the uses of java return

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the uses of java return". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the uses of java return"?

1. In a method with a return value, return the value of the specified type of the method, and end the execution of the method at the same time

Second, it can also be used in a method with a return value of void to terminate the operation of the method

Break and return

Break is used to jump out of the loop, for example, for,while,do-while can jump out, but not out of the function

Return causes the entire function to return, and the rest is not executed either inside or outside the loop

1. You can return null in a method with an object reference return type

Public Button doStuff () {return null;}

two。 Array is a perfectly legal return type

Public String [] go () {return new String [] {"wangsan", "wangsan", "wangsi"};}

3. Within a method with a basic return type, you can return any value or variable, as long as they can be implicitly converted to the declared return type

Public int foo () {char centering; return crescendo can be converted into int}

4. Within a method with a basic return type, you can return any value or variable, as long as they can display a cast to the declared return type (this is not an example)

5. You must not return any value (^ _ ^) from a method with a return type of void, and of course you can interrupt the program with return.

Public void bar (int a) {/ / negative number interrupts the operation, if (a)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report