클래스 함수 사용하기
class Student{
int id;
String name;
double score;
int sum;
void calcScore(){
int[] students = new int[]{90,80,70,80,100};
for(int i=0;i<students.length;i++){
sum += students[i];
}
}
void print(){
System.out.println("ID ="+id+" Name ="+name+
" score= "+sum);
}
}
public class StudentTest {
public static void main(String[] args) {
Student lee = new Student();
lee.id = 140101;
lee.name = "이학생";
lee.calcScore();
System.out.println(lee.sum);
lee.print();
}
}