ทำไมถึงสำหรับวงในของจาวาทำให้ได้ผลลัพธ์ที่แตกต่างกันถ้าเราเอาอวกาศในห้องพิมพ์แถลงการณ์และก็พิมพ์ตัวแปร

0

คำถาม

public class Countingtable {
    public static void main(String[] args) {
        // write a program to count/increase a number by 2 everytime.
        int number1;
        for (number1 = 2; number1 <= 20; number1++)
            System.out.println("this number is a multiple of 2  " + number1);
    }
}

โปรดจำไว้ว่าถ้าฉันลบพื้นที่ในห้องพิมพ์แถลงการณ์มันทำให้ได้ผลลัพธ์ที่แตกต่างกัน? มีเบาะแสนจะช่วยและรู้สึกขอบคุณ

System.out.println("this number is a multiple of 2" + number1);
java
2021-11-24 06:52:27
1

คำตอบที่ดีที่สุด

-1

อันนี้ตลกหนึ่ง คุณเห็นตอนที่คุณทำให้พื้นที่แสดงผลเป็นอย่างที่คุณหวังว่า

This number is multiple of 2 2
This number is multiple of 2 3
This number is multiple of 2 4

แต่ตอนที่คุณลบพื้นที่คำตอบยังคือมาตกแต่มันกำลังจะเข้าร่วมกับหมายเลข 2 ในแถลงการณ์ i.e.

This number is multiple of 22 -- here 2 is from the statement and the next one is from answer
This number is multiple of 23 -- here 2 is from the statement and the next one is from answer
This number is multiple of 23 -- here 2 is from the statement and the next one is from answer
2021-11-24 07:02:48

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่