"예전에는 컴퓨터가 텍스트만 표시할 수 있었습니다. 프로그램은 키보드 입력을 받아 화면에 데이터를 표시했습니다. 이를 '콘솔 사용자 인터페이스' 또는 간단히 '콘솔'이라고 합니다. 윈도우 인터페이스는 콘솔의 대안입니다. 이러한 유형의 인터페이스에서 사용자는 하나 이상의 창을 통해 프로그램과 상호 작용합니다. 프로그래밍 방법을 배우는 중이므로 콘솔 작업부터 시작하겠습니다."

"괜찮은."

"텍스트는 콘솔(화면)에 한 줄씩 연속적으로 표시됩니다. 텍스트는 키보드를 사용하여 입력됩니다. 실수를 방지하기 위해 키보드 입력이 화면에 표시됩니다. 때로는 인간 사용자와 프로그램이 번갈아 가며 나타나는 것처럼 보입니다 . 화면에 글을 쓰세요. "

" System.out.print () 메서드를 사용하여 화면에 텍스트를 표시할 수 있습니다. 이 메서드는 단순히 텍스트를 표시하는 반면 System.out.println ()은 텍스트를 표시하고 커서를 다음 줄로 이동합니다."

암호 결과
System.out.print("Rain");
System.out.print("In");
System.out.print("Spain");
RainIn스페인
System.out.print("Rain");
System.out.println("In");
System.out.print("Spain");

스페인에서
System.out.println("Rain");
System.out.println("In");
System.out.println("Spain");
스페인
의 비

"텍스트를 분리하려면 공백을 추가해야 합니다. 예를 들면 다음과 같습니다."

암호 결과
int a = 5, b = 6;
System.out.print(a);
System.out.print(b);
56
int a = 5, b = 6;
System.out.print(" " + a + " " + b);
 5 6
int a = 5, b = 6;
System.out.print("The sum is " + (a + b));
The sum is 11

"알았어요"

"이렇게 하면 화면에 무엇이든 표시할 수 있습니다. 모든 Java 개체를 문자열로 변환할 수 있습니다. 모든 Java 클래스는 toString() 메서드가 있는 Object 클래스에서 파생됩니다. 이 메서드는 개체를 끈."

암호 설명
Cat cat = new Cat("Oscar");
System.out.println("The cat is " + cat);
이 세 가지 예는 동일합니다.
Cat cat = new Cat("Oscar");
System.out.println("The cat is " + cat.toString());
Cat cat = new Cat("Oscar");
String catText = cat.toString();
System.out.println("The cat is " + catText);
3
과제
Java Syntax,  레벨 3레슨 3
잠금
Display right away
Programming isn't always difficult. Sometimes you need to do simple tasks. And the more similar tasks you have to do, the more you want to automate them. Let's implement one more method. Ultimately, objects without methods don't do anything. We'll pass the string s to the method, which will then display it on the screen.

"하지만 내 프로그램은 ' The cat is com.codegym.lesson3.Cat@1fb8ee3 '을 표시했습니다. 도대체 그게 무슨 뜻일까요?"

"객체 클래스의 표준 toString() 메서드는 클래스 이름객체의 메모리 주소 (16진수 형식) 로 구성된 문자열을 반환합니다 ."

"어허. 그런 방법이 무슨 소용이 있겠어?"

"클래스에 toString() 구현을 직접 작성할 수 있습니다. 그러면 이것이 호출될 메서드입니다."

"정말요? 좋습니다."

"여기 디에고의 몇 가지 작업이 있습니다."

3
과제
Java Syntax,  레벨 3레슨 3
잠금
Currency exchange
Loan sharking, sales, banking: do you have a backup plan if programming doesn't work out? No? In that case, let's help traders and financiers with our top-notch programs. First, we'll organize a currency exchange: write a program that converts euros to dollars at a given exchange rate.
3
과제
Java Syntax,  레벨 3레슨 3
잠금
Task with percentages
If you weren't afraid of problems with percentages in school, then this problem won't scare you either. But if you do suddenly find yourself afraid, it's time to face your fear and realize that this is actually a simple and pleasant topic. Let's implement a method that increases the passed integer by 10 percent.
1
과제
Java Syntax,  레벨 3레슨 3
잠금
Code entry
Your attention, please! Now recruiting code entry personnel for CodeGym. So turn up your focus, let your fingers relax, read the code, and then... type it into the appropriate box. Code entry is far from a useless exercise, though it might seem so at first glance: it allows a beginner to get used to and remember syntax (modern IDEs seldom make this possible).