본문 바로가기
Java

java-입력을 배열에 저장, 수정

by zenna 2022. 1. 24.
728x90

package Java_Basic;

import java.util.Arrays;
import java.util.Scanner;

public class Prac3 {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String a = input.nextLine();
		String[] arr = a.split("");
		for (int i = 0; i < arr.length; i++) {
			if (arr[i].equals(" ")) {
				arr[i] = ",";
			}
		}
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i]);
		}

	}
}
728x90

댓글