【习题38】

作者: Xplorist | 来源:发表于2017-04-19 22:15 被阅读3次

【程序38】
题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。

package com.share.test31_40;

import java.util.Scanner;

public class Test38 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入您要输入的字符串:");
        String str=sc.nextLine();
        test(str);
    }
    public static void test(String str){
        System.out.println(str.length());
    }
}

相关文章

网友评论

    本文标题:【习题38】

    本文链接:https://www.haomeiwen.com/subject/kotkzttx.html