Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

개발기록

Illegal start of type 본문

JAVA/ERROR

Illegal start of type

옥수수수염챠 2020. 3. 11. 21:15
Rand.java:77: illegal start of type
        return result ;
        ^

return문이 대괄호 밖에 있을때 발생하는 오류

 

필자는 타이핑 오류로 아래와 같이 괄호 오타가 발생하여 생겼다.

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {}
        
        int tmp = 0;
        int tmp_rst = 0;
        while((l1 != null) && (l2 != null)){
            tmp_rst = 0;
            tmp_rst = l1.val + l2.val + tmp;
            tmp = tmp_rst / 10;
            ListNode result = new ListNode(tmp_rst % 10);
            result.next = new ListNode();
           
            l1 = l1.next;
            l2 = l2.next;
        }
        return result;
    }
    
}