static int add(int a, int b) {
return a + b;
}
main() 메서드는 자바 프로그램의 시작점int... numbers 형식 사용static int addAll(int... numbers) {
int total = 0;
for (int n : numbers) total += n;
return total;
}
int[] multiReturn(int n1, int n2) {
return new int[] { n1 + n2, n1 - n2 };
}
public static void push(String food) {
String[] temp = new String[foods.length + 1];
... // 기존 값 복사 후 마지막에 삽입
foods = temp;
}
indexOf(), include() 등 검색 기능도 직접 구현class Dancer {
String dancerName;
String crewName;
String[] genres;
int danceLevel;
void dance() { ... }
void introduce() { ... }
}
Dancer(String name, String crew, String... genres) {
this.dancerName = name;
this.crewName = crew;
this.genres = genres;
}
void deposit(double amount) { ... }
void withdraw(double amount) { ... }
void displayBalance() { ... }
void updateGrade() { ... }
void printStudentInfo() { ... }
✅ 총정리