목록분류 전체보기 (601)
sm 기술 블로그
Object 모든 클래스들의 조상 toString() class Calculator{ int left, right; public void setOprands(int left, int right){ this.left = left; this.right = right; } public void sum(){ System.out.println(this.left+this.right); } public void avg(){ System.out.println((this.left+this.right)/2); } } public class CalculatorDemo { public static void main(String[] args) { Calculator c1 = new Calculator(); c1.setOpran..
예외(Exception) 예상하지 못한, 예기치 못한 오류를 어떻게 처리하는가 package org.opentutorials.javatutorials.exception; class Calculator{ int left, right; public void setOprands(int left, int right){ this.left = left; this.right = right; } public void divide(){ System.out.print("계산결과는 "); System.out.print(this.left/this.right); // 이 부분의 문제로 System.out.print(" 입니다."); } } public class CalculatorDemo { public static void ..
1. 1000 import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int a, b; a = sc.nextInt(); b = sc.nextInt(); System.out.println(a + b); } } 2. 1001 import java.util.*; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println(sc.nextInt()-sc.nextInt()); } 3. 10171 import java.util.*; pu..