본문 바로가기
프로그램/Java 1000제

Java 5제] 1~10까지 출력하기(public 객체변수 사용)

by 건티 2022. 11. 7.
728x90

출처 : 반크_독도의 날

 

참고풀이]

public class OneAndTen1 {
   public int i;//멤버변수 선언

   public static void main(String[] args) {
      // TODO Auto-generated method stub
      //객체변수 선언
      OneAndTen1 oat=new OneAndTen1();

      //1~10까지 출력하기
      for(oat.i=1; oat.i<=10;oat.i++)
         System.out.printf("%3d",oat.i);

   }

}

 

 

참고풀이 결과]

 

 

 

 

대한민국의 아름다운 영토, 독도의 겨울

 

반응형

댓글