<i id='NvxiH'><tr id='NvxiH'><dt id='NvxiH'><q id='NvxiH'><span id='NvxiH'><b id='NvxiH'><form id='NvxiH'><ins id='NvxiH'></ins><ul id='NvxiH'></ul><sub id='NvxiH'></sub></form><legend id='NvxiH'></legend><bdo id='NvxiH'><pre id='NvxiH'><center id='NvxiH'></center></pre></bdo></b><th id='NvxiH'></th></span></q></dt></tr></i><div id='NvxiH'><tfoot id='NvxiH'></tfoot><dl id='NvxiH'><fieldset id='NvxiH'></fieldset></dl></div>
<legend id='NvxiH'><style id='NvxiH'><dir id='NvxiH'><q id='NvxiH'></q></dir></style></legend>
<tfoot id='NvxiH'></tfoot>

      • <bdo id='NvxiH'></bdo><ul id='NvxiH'></ul>
    1. <small id='NvxiH'></small><noframes id='NvxiH'>

    2. 如何以相反的顺序获取 char 数组?

      时间:2023-07-26
        <tbody id='Fm6eZ'></tbody>

      • <bdo id='Fm6eZ'></bdo><ul id='Fm6eZ'></ul>
        <legend id='Fm6eZ'><style id='Fm6eZ'><dir id='Fm6eZ'><q id='Fm6eZ'></q></dir></style></legend>

              <small id='Fm6eZ'></small><noframes id='Fm6eZ'>

              <tfoot id='Fm6eZ'></tfoot>
              • <i id='Fm6eZ'><tr id='Fm6eZ'><dt id='Fm6eZ'><q id='Fm6eZ'><span id='Fm6eZ'><b id='Fm6eZ'><form id='Fm6eZ'><ins id='Fm6eZ'></ins><ul id='Fm6eZ'></ul><sub id='Fm6eZ'></sub></form><legend id='Fm6eZ'></legend><bdo id='Fm6eZ'><pre id='Fm6eZ'><center id='Fm6eZ'></center></pre></bdo></b><th id='Fm6eZ'></th></span></q></dt></tr></i><div id='Fm6eZ'><tfoot id='Fm6eZ'></tfoot><dl id='Fm6eZ'><fieldset id='Fm6eZ'></fieldset></dl></div>

                本文介绍了如何以相反的顺序获取 char 数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我的作业题是这样的

                编写一个程序,以相反的顺序打印字符数组中的字母

                Write a program which prints the letters in a char array in reverse order using

                void printReverse(char letters[], int size);
                

                例如,如果数组包含 {'c', 's', 'c', '2', '6', '1'},则输出应为162csc".

                For example, if the array contains {'c', 's', 'c', '2', '6', '1'} the output should be "162csc".

                试过了,不知道什么意思

                I tried, but I don't know what it means

                void printReverse(char letters[], int size);
                

                我这样做了,但调用方法printReverse"时出现问题.进入main方法

                I did this but there's a problem with calling the method "printReverse" into the main method

                import java.util.Arrays;
                import java.util.Collections;
                 
                public class search {
                
                    public static void main(String[] args) {          
                 
                        char[] letters = {'e', 'v', 'o', 'l', '4'};
                        printReverse();
                
                    }
                
                    public void printReverse(char[] letters, int size) {
                    
                        for (int i = letters.length-1; i >= 0 ; i--) {
                        System.out.print(letters[i]);
                    }
                }
                

                推荐答案

                我相信你写的就是你必须创建的方法的签名.

                I believe what you wrote is the signature of the method you have to create.

                public void printReverse(char[] letters, int size){
                   //code here
                }
                

                您必须迭代数组并向后打印它包含的内容.使用反向for 循环"遍历字母"中的每个项目.我会让你自己把这些结合起来,因为这是一项任务.下面是一个 for 循环的例子:

                You would have to iterate the array and print what it contains backwards. Use a reverse "for loop" to go through each item in "letters". I'll let you combine these yourself as it's an assignment. Here's an example of a for loop:

                for (int i = array.length-1; i >= 0 ; i--){
                    System.out.print(array[i]);
                }
                

                这篇关于如何以相反的顺序获取 char 数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:您可以将字符与 == 进行比较吗? 下一篇:逐个字符比较java中的两个字符串

                相关文章

                最新文章

                • <bdo id='a5ChM'></bdo><ul id='a5ChM'></ul>
                <tfoot id='a5ChM'></tfoot>
              • <small id='a5ChM'></small><noframes id='a5ChM'>

                  1. <i id='a5ChM'><tr id='a5ChM'><dt id='a5ChM'><q id='a5ChM'><span id='a5ChM'><b id='a5ChM'><form id='a5ChM'><ins id='a5ChM'></ins><ul id='a5ChM'></ul><sub id='a5ChM'></sub></form><legend id='a5ChM'></legend><bdo id='a5ChM'><pre id='a5ChM'><center id='a5ChM'></center></pre></bdo></b><th id='a5ChM'></th></span></q></dt></tr></i><div id='a5ChM'><tfoot id='a5ChM'></tfoot><dl id='a5ChM'><fieldset id='a5ChM'></fieldset></dl></div>
                    <legend id='a5ChM'><style id='a5ChM'><dir id='a5ChM'><q id='a5ChM'></q></dir></style></legend>