# 계좌 이체 public boolean transfer(Account target, int amount) { ... } : transfer 메소드의 정의 부분에서 입력변수가 (Account target, int amount) 인데, 어떻게 클래스 명을 변수로 받을 수 있는지 궁금합니다. 혹시 제 질문이 이해가 잘 안신다면 transfer 메소드 정의 부분을 설명해주시면 감사하겠습니다. 감사합니다. #### CODE <a class='btn btn-default' href='/codes/90313'>Link</a> ``` public class AccountTest { public static void main(String[] args) { // 객체 생성 Account a = new Account("123-45", 10000); Account b = new Account("567-89", 10000); // 송금: 3천원씩 a 계좌에서 -> b계좌로! boolean result = true; while (result) { result = a.transfer(b, 3000); } // 결과 출력 System.out.println(a.toString()); System.out.println(b.toString()); } } class Account { String num; // 계좌번호 int balance; // 잔액 public Account(String str, int i) { num = str; balance = i; } public String toString() { return String.format("Account { num: %s, balance: %d }", num, balance); } public boolean transfer(Account target, int amount) { if (/* 1. 잔액이 부족한 경우 false를 반환하세요. */) { return false; } /* 2. 현재 잔액에서 송금액을 이체대상 계좌로 전달하세요. */ // balance -= ??; // target.balance += ??; return true; } } ``` #### INPUT ``` ; ``` #### OUPUT ``` /root/var/tmp/2023_04_15_14_18_44_8dfde1d5/AccountTest.java:33: error: illegal start of expression if (/* 1. 잔액이 부족한 경우 false를 반환하세요. */) { ^ 1 error ```
자바 레퍼런스 변수를 조사해보세요 파라미터는 특정 객체를 가리킬 수 있는 즉, 레퍼런스 변수를 가질 수 있습니다