import java.util.Scanner;

public class practice {

	public void inputArr(){
        Scanner sc = new Scanner(System.in);
        System.out.print("행의 갯수를 입력하고 [Enter]를 치세요 = ");
        int R = sc.nextInt();
        System.out.print("열의 갯수를 입력하고 [Enter]를 치세요 = ");
        int C = sc.nextInt();

        char[][] gamemap = new char[R][C];
        String[] strAr = new String[R];

        for(int i = 0; i < R; i++){
            System.out.printf("%s행의 문자를 입력해주세요(길이제한 %s) = ", i+1,C);
            strAr[i] = sc.next();
            if(strAr[i].length() > C){
                System.out.print("ERROR!");
                break;
            }
            for(int j = 0; j < C; j++){
                gamemap[i][j] = strAr[i].charAt(j);
            }
        }
        System.out.print(Arrays.deepToString(gamemap));
    }

	public static void main(String[] args){
		practice test = new practice();
		test.inputArr();		
	}
}

//행의 갯수를 입력하고 [Enter]를 치세요 = 3
//열의 갯수를 입력하고 [Enter]를 치세요 = 3
//1행의 문자를 입력해주세요(길이제한 3) = abc
//2행의 문자를 입력해주세요(길이제한 3) = def
//3행의 문자를 입력해주세요(길이제한 3) = ghi
//[[a, b, c], [d, e, f], [g, h, i]]

입력값을 긁을 때 쓰나봄

아직 실전에 사용한 적은 없지만 알고리즘 연습시 테스트할 때 인풋하기 편할 듯

사용법

Scanner 변수명(sc) = Scanner(System.in);

※System.in은 자바의 입력 스트림이라고 함...

sc.nextByte()		// byte 형 입력 및 리턴
sc.nextShort()		// short 형 입력 및 리턴
sc.nextInt()		// int 형 입력 및 리턴
sc.nextLong()		// long 형 입력 및 리턴
 
sc.nextFloat()		// float 형 입력 및 리턴
sc.nextDouble()		// double 형 입력 및 리턴
 
sc.nextBoolean()	// boolean 형 입력 및 리턴
 
sc.next()			// String 형 입력 및 리턴	(공백을 기준으로 한 단어를 읽음)
sc.nextLine()		// String 형 입력 및 리턴 (개행을 기준으로 한 줄을 읽음)

sc.next와 sc.nextLine의 경우 공백과 Enter입력 때문에 문제가 생길 수 있음.