如何从另一种方法中找到String的长度?

时间:2017-01-15 16:27:07

标签: java methods

package hollyhw;

import java.util.Random;
import java.io.*;

public class HollyHW {
    public static int censor(String chars){
  

我尝试实施以下内容。但是,我没有管理。

        int letters = chars.length();
        int newLetters = letters;

        return newLetters;   
    }
  

请注意,对于此特定任务,我无法编辑void main。

    public static void main(String[] args) {
        String c1 = censor("short"); //IDE is suggesting to change to int.
        String c2 = censor("longer the short"); //IDE is suggesting to change to int.
        String c3 = censor("the longest one we've got"); //IDE is suggesting to change to int.

        print(c1);
        print(c2);
        print(c3);
        print("");
    }
}

1 个答案:

答案 0 :(得分:1)

你可以这样做:

<!-- listbox showing large icon -->

<listbox>
<listitem label="Widdershins"
      class="listitem-iconic"
      image="http://www.widdershinscomic.com/favicon.ico"
      style="max-height: 18px;"
/>
<listitem label="Darken"
      class="listitem-iconic"
      image="http://darkencomic.com/wp-content/themes/inkblot/includes/images/icon.png"
      style="max-height: 18px;"
/>

</listbox>

<!-- menu shows no icons at all but when you select the 'darken' one you get a huge icon -->

<menulist label="label" accesskey="{accesskey}">
<menupopup>
<menuitem label="Widdershins"
      class="menuitem-iconic"
      image="http://www.widdershinscomic.com/favicon.ico"
      style="max-height: 18px;"
/>
<menuitem label="Darken"
      class="menuitem-iconic"
      image="http://darkencomic.com/wp-content/themes/inkblot/includes/images/icon.png"
      style="max-height: 18px;"
/>
</menupopup>
</menulist>
</window>