목록전체 글 (28)
S.S.G
Wrapper 클래스 활용 예시 - 8개의 기본 데이터를 객체 형식으로 다루기 위해 JDK에 의해 지원되는 8개의 클래스를 통칭하여 Wrapper 클래스라고 한다 (Wrapper 클래스 타입 = Byte, Short, Integer, Long, Character, Float, Double, Boolean) public class Test { public static void main(String arg[]) { Integer i = new Integer(10); char c = '9'; Double d = new Double(3.1234566); System.out.println(Character.toLowerCase('A')); // 대문자 'A'를 소문자로 변환 if (Character.isDigit..
int 타입의 width, height의 필드를 가지는 Rect 클래스를 작성하고, 두 Rect 객체의 width, height필드에 의해 구성되는 면적이 같으면 두 객체가 같은 것으로 판별하도록 equals()를 작성해보기. class Rect { int width; int height; public Rect(int width, int height) { this.width = width; this.height = height; } public boolean equals(Rect p) { if (width * height == p.width * p.height) return true; else return false; } } public class Test { public static void main(..
함수를 완성해서 매개변수 list의 평균값을 return 하도록 만들어 보기 public class Test { public int getAvg(int[] array) { int sum = 0; for(int i=0; i
* static 필드와 메소드를 이용하여 달러와 우리나라 원화 사이의 변환을 해주는 가단한 환율 계산기 public class Test { public static void main(String arg[]) { CurrentConverter.setRate(1160); // 미국 달러 환율 $1 는 1160원 System.out.println("백만원은 " + CurrentConverter.toDollar(1000000) + " 입니다."); System.out.println("백달러는"+ CurrentConverter.toKWR(100) + "원입니다."); } } class CurrentConverter { private static double rate; // 한국 원화에 대한 환율을 나타냄 publ..