자바 기초질문입니다 도와주세요

자바 기초질문입니다 도와주세요

QA

자바 기초질문입니다 도와주세요

본문

입력받은값을 비교하는 두수 비교하기 백준 문제입니다.

if문에 

error: illegal start of type

!error: <identifier> expected

이라고 뜨는데 왜그런가요??

 

클래스를 하나 더만들어 메인 메소드에 가지고 오는게 안되나요??

 

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        IfChecker ic = new IfChecker();
        ic.setValue(this.A, this.B);
        ic();
    }
}

class IfChecker {
    int A, B;
    void setValue(int a ,int b){
        A = a;
        B = b;
    }
    if(A > B) {
         return   System.out.println(">");
        } else if(A < B) {
        return      System.out.println("<");
        } else {
        return      System.out.println("==");
        }
}

이 질문에 댓글 쓰기 :

답변 2

class IfChecker {
    int A, B;
    void setValue(int a ,int b){
        A = a;
        B = b;
    }

void somefunc( int A ,int B){
    if(A > B) {
         return   System.out.println(">");
        } else if(A < B) {
        return      System.out.println("<");
        } else {
        return      System.out.println("==");
        }

}
}

 

함수를 하나 더 만드세요.

답변을 작성하시기 전에 로그인 해주세요.
전체 97
QA 내용 검색
filter #java ×

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT