Java循环拼接字符串

package computerPractice;

import java.util.Scanner;

public class StringSplicing {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String str = "", splice = "";
		do {
			System.out.print("请输入一个字符串(输入000退出):");
			str = sc.next();
			splice += str;
			if (str.equals("000")) {
				break;
			} else {
				System.out.println();
			}
		} while (!"000".equals(str));
		System.out.println("\n您输入的字符串的完整展示为:" + splice);

		sc.close();

	}

}

你可能感兴趣的:(典化成籍-Java)