在java中打印返回的字符串

时间:2015-10-30 00:57:14

标签: java string methods

我正在尝试在main方法中打印返回的字符串值,但我无法弄明白。有人可以帮我一把吗?

import java.util.Scanner;


public class Main {


public static void main(String[] args) {


    String in_word;
    int number_input;

    Scanner input_word = new Scanner (System.in);
    Scanner input_times = new Scanner (System.in);


    System.out.println("Enter word: ");
    in_word = input_word.next();
    System.out.println("Enter number of times to concatenate: ");
    number_input = input_times.nextInt();



    multiConcat(in_word, number_input);

}
public static String multiConcat(String word, int times) {
    //String word;
    String s = "";
    int number;//times, ;


    for (number = 0; number < times; number++)
        s = word.concat(s);

    return s;

}


}

1 个答案:

答案 0 :(得分:2)

System.out.println(multiConcat(in_word, number_input));