Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

An example Analysis of the return value of java method

Shulou Source: shulou.com Published: 2022-05-31 10:53:36 09月23日 Update

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!

Tags: Method array instance instance analysis analysis type result sort content learning practical deeper code function key keyword interest premise name character Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Redmi MySQL Linux