Written by
java-style
on
on
자바의 배열
자바의 배열
-
좋아요
배열이란?
1. 단 한개의 자료형 타입으로 복수 자료형 값을 저장할 때 배열을 사용한다.
2. 배열은 고정된 크기이다.
3. 배열의 주소 시작번호값은 0이다.
<배열 예제>
- 배열값을 저장하는 방법1
package test; public class ArrayTest01 { public static void main(String[] args) { int[] score=new int[3];//배열크기가 3인 정수형숫자 배열 score생성 score[0]=100; score[1]=90; score[2]=90; System.out.println("score 배열크기="+score.length); for(int i=0;i
<배열 예제 2>
- 배열값을 저장하는 방법2
package test; public class ArrayTest02 { public static void main(String[] args) { String[] name={"홍길동","이순신","강감찬"}; //배열크기가 3인 name배열 생성 System.out.println("name 배열크기=>"+name.length); for(int j=0;j<3;j++){ System.out.println(name[j]); } } }
from http://betterwave.tistory.com/12 by ccl(A) rewrite - 2021-11-25 01:28:00