반응형
getter and setter in generate
보이는 바와 같이,
ball 클래스에서 만든 properties들을 getter, setter을 이용해 method로 만들어준 후,
main에서 불러와서 set(초기화)하거나 get(불러오기)할 수 있다.
package com.company;
public class ball {
//getter and setter
private char name;
public char getName() {
return name;
}
public void setName(char name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
private int number;
}
package com.company;
public class Main {
public static void main(String[] args) {
ball what = new ball();
what.setNumber(2);
}
}
쓰레드(하드웨어적 설명)
-쉽게 설명하자면, cpu라는 친구가 일을 하는데, thread라는 직원을 고용하여,
cpu가 하는 일을 thread라는 친구에게 일을 시킨다.
쓰레드(소프트웨어적 설명)
-하나의 흐름(코드로 제어가 필요한 하나의 흐름)
예를 들어 게임에서, 내가움직이는 유저가 있다면
적군을 움직이는 쓰레드가 있고, 날씨를 조작하는 쓰레드가 있고 등등
Array
package com.company;
public class Main {
public static void main(String[] args) {
// 기본 array
int[] numbers = {1,2,3,4,5};
String[] information = {"my", "name" , "is" , "hoon"};
//System.out.println(information[4]);
//ㅋ
for (int i = 0; i < information.length; i++) {
System.out.println(information[i]);
}
//응용
int[] myArray = new int[3];
myArray[0] = 2;
myArray[1] = 3;
myArray[2] = 15;
System.out.println(myArray[0]);
}
}
반응형
'개발언어 > JAVA' 카테고리의 다른 글
자바 간단한 어플 만들기. (0) | 2020.11.14 |
---|---|
자바 VIEW (0) | 2020.11.11 |
자바 Iterator , hashmap, map (0) | 2020.11.04 |
자바 클래스; 복습 (0) | 2020.10.30 |
JAVA (0) | 2020.03.14 |