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

An example Analysis of the return value of java method

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly talks about "the example analysis of the return value of java method". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "java method return value example analysis" bar!

1. The return value of a method refers to the result of executing the code in the body of a method. The premise is that this method may produce results.

2. The function of the return value: to receive the result so that it can be used in other operations.

If a method has a return value, it must be returned using the keyword return, which is the type of the method.

Example

Package com.jredu.ch09;import java.util.Arrays;import java.util.Scanner;/** * method with return value * get the sorted array * @ author Administrator * * / public class Ch05 {public Scanner input;public String [] name = new String [5]; public Ch05 (Scanner input) {super (); this.input = input } public String [] student () {/ / the return value type is an array System.out.println ("Please enter the names of 5 students"); for (int I = 0; I < name.length; iTunes +) {name [I] = input.next ();} Arrays.sort (name); / / an array to sort System.out.println ("* sorted *"); return name / / return array name} public static void main (String [] args) {Ch05 d = new Ch05 (new Scanner (System.in)); System.out.print (Arrays.toString (d.student ()) + "\ t") / / d.student (): call the return value / / Arrays.toString (d.student ()): convert the array to a string}} so far. I believe you have a deeper understanding of "instance analysis of the return value of the java method". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Internet Technology

Wechat

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

12
Report