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

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
자바 기초질문입니다 도와주세요

QA

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

답변 2

본문

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

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("==");
        }

}
}

 

함수를 하나 더 만드세요.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
filter #java ×
전체 98
© SIRSOFT
현재 페이지 제일 처음으로