본문 바로가기

Java 배우기145

Formatting Numeric Print Output Formatting Numeric Print Output 앞서 표준 출력 (System.out)에 문자열(strings)을 인쇄하기 위한 print 및 println 메소드의 사용을 보았습니다. (이 단원 후반에서 보겠지만) 모든 숫자를 문자열로 변환시킬 수 있기 때문에, 문자열과 숫자의 임의의 혼합물을 인쇄하기 위해 이러한 메소드들을 사용할 수 있습니다. 하지만 자바 프로그래밍 언어는 숫자들이 포함되어 있을 때, 인쇄 출력을 보다 더 많이 제어할 수 있게 하는 다른 메소드들도 갖고 있습니다.Earlier you saw the use of the print and println methods for printing strings to standard output (System.out). Since all.. 2016. 1. 5.
The Numbers Classes 숫자 클래스들 숫자 클래스들 The Numbers Classes 숫자로 작업할 때, 대부분의 경우 코드에서 원시타입을 사용합니다. 예를 들면: When working with numbers, most of the time you use the primitive types in your code. For example:int i = 500; float gpa = 3.65f; byte mask = 0xff; 하지만 원시 타입 대신 객체를 사용하는 이유가 있으며, 자바 플랫폼은 각각의 원시데이터타입에 대하여 클래스 wrapper를 제공합니다. 이들 클래스 wrapper는 객체 안에서 원시타입을 "wrap" 합니다. 컴파일러가 wrapping을 수행하는 경우도 많습니다 - 객체가 예상되는 곳에 원시타입이 사용된다면, 컴파일러.. 2016. 1. 5.
Numbers 숫자 숫자 Numbers 이 섹션은, 패키지 java.lang, 그 하위클래스들의 안이나, 그리고 원시숫자타입 대신 이들 클래스를 인스턴스화를 사용할 상황에서의 클래스 Number에 대한 논의로 시작합니다. 이 섹션은 또한 클래스 PrintStream과 DecimalFormat을 제시하는데, 이것은 formatted numerical output의 작성을 위한 메소드를 제공합니다. This section begins with a discussion of the Number class in the java.lang package, its subclasses, and the situations where you would use instantiations of these classes rather than the.. 2016. 1. 5.
Lesson: Numbers and Strings 단원: 숫자와 문자 단원: 숫자와 문자 Lesson: Numbers and Strings숫자 Numbers 이 섹션은 (java.lang 패키지 안의) 클래스 Number와 그 하위클래스에 대한 논의로 시작합니다. 특히 이 섹션에서는 이러한 원시 데이터타입이 아닌 이들 클래스들의 인스턴스화를 사용할 상황에 대해 이야기합니다. 또한 이 섹션에서는 연산자가 언어로 구축되어 들어가도록 하는 수학 함수의 포맷팅 및 사용과 같은, 숫자와 작업하는데 필요할 수있는 다른 클래스에 대해 이야기합니다. 마지막으로, 오토박싱과 언박싱, 코드를 단순화하는 컴파일러 기능에 대한 논의를 합니다. This section begins with a discussion of the Number class (in the java.lang package) .. 2016. 1. 5.
Questions and Exercises: Inheritance 질문과 연습: 상속 질문과 연습: 상속 Questions and Exercises: InheritanceQuestions1. Consider the following two classes:public class ClassA { public void methodOne(int i) { } public void methodTwo(int i) { } public static void methodThree(int i) { } public static void methodFour(int i) { } } public class ClassB extends ClassA { public static void methodOne(int i) { } public void methodTwo(int i) { } public void methodThr.. 2016. 1. 5.
Summary of Inheritance 상속 요약 상속 요약 Summary of Inheritance 클래스 Object를 제외하고, 1개의 클래스는 정확히 1개의 직접 수퍼클래스를 갖고 있습니다. 클래스는 모든 그 수퍼클래스들로부터 직접 또는 간접적으로 필드들과 메소드들을 상속받습니다. 서브클래스는 상속받는 메소드를 override 할 수 있으며, 또는 상속받는 필드들이나 메소드들을 감출 수 있습니다(필드 감추기는 나쁜 프로그래밍 습관입니다). Except for the Object class, a class has exactly one direct superclass. A class inherits fields and methods from all its superclasses, whether direct or indirect. A subclass .. 2016. 1. 5.