자바의 신 - 클래스, 메소드, 객체

Yumin Jung·2023년 11월 4일
0

자바의 신

목록 보기
1/4
post-thumbnail
public class Profile{
    String name;
    int age;
    public static void main(String args[]){
        Profile profile=new Profile();
        profile.setName("Min");
        profile.setAge(20);
        profile.printName();
        profile.printAge();
    }

    public void setName(String str){
        name= str;
    }
    public void setAge(int val){
        age=val;
    }
    public void printName(){
        System.out.println("My name is "+name);
    }

    public void printAge(){
        System.out.println("My age is "+age);
    }
}
profile
문과를 정말로 존중해

0개의 댓글