Java - Array

2022. 5. 23. 12:29Java

Definition of Array

: Arrays are used to store multiple values in a single variable, instead of declearing seperate values for each value.

 

Declear Array

String[] cars = {"Volvo", "Bmw", "Ford", "Manza"}

 

int [] score = new int [10]

Access the Element of an Array

String cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars[0]); //Output Volvo

Array Length

String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars.length); //Outputs 4

배열의 출력

for(int i = 0; i < 10; i ++)

  System.out.println(score[i]);

배열의 복사

int tmp[] = new tmp[10];
for(int i = 0; i < 10; i ++){
	temp[i] = score[i];
}

 

 

*References

https://www.w3schools.com/java/java_arrays.asp

 

Java Arrays

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

남궁 성, ⌜자바의 정석⌟, 2016.1.27

'Java' 카테고리의 다른 글

[Java] 변수  (0) 2024.02.22
[Java] 자바의 특징  (0) 2024.02.22
Java 버전 바꾸기 Mac M2 air  (1) 2023.12.26
Java - Object-oriented programming II  (0) 2022.07.11
Java - Object-oriented programming I  (0) 2022.06.27