ABOUT ME

Today
Yesterday
Total
  • Java - 배열에 문자열 집어넣기.
    개발노하우/Java 2007. 4. 19. 00:43

    import java.io.*;

    class Text_input{
     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
     
     String str[] = new String[5];
     
     public void disp()throws IOException{
      for(int i=0;i<str.length;i++){
       System.out.println("입력하고자 하는 글자를 넣어주세요.// ");
       str[i] = in.readLine();
      }
     }
     public void disp_txt()throws IOException{
      for(int j=0;j<str.length;j++){
       System.out.println(str[j]);
      }
     }
    }

    public class member_s{
     public static void main(String arg[])throws IOException{
      Text_input tx = new Text_input();
      tx.disp();
      tx.disp_txt();
     }
    }

Designed by Tistory.