
커스텀 자료형이란 정수나,문자 하나의 타입만 담는 것 이 아닌 두 개의 타입을 하나의 커스텀 자료형으로 묵어 담을 수 있는 자료형이다.
ex)작은 모양이 다른 두 개의 그릇을 큰 그릇에 담는다고 생각하면 된다.
class
package ex04;
class Person1{ // class는 커스텀 자료형이다.
static int age = 20;
static char gender = '여';
}
public class MemEx01 {
public static void main(String[] args) {
System.out.println(Person1.age);
System.out.println(Person1.gender);
}
}
String
string은 클래스 자료형으로 문자열을 담는다.
package ex03;
public class PizzaTopping {
public static void main(String[] args) {
String[] toppings = {"Pepperon1", "Mushrooms", "Onions", "Sausage", "Bacon"};
for (String s : toppings){
System.out.print(s + " ");
}
}
}
}
Share article