Xiaobai on the System.out.println problem

1,


import java.util.*;  

public class Main {

    public static void main(String[] args) {
        int[] arr=new int[4];
        Scanner in=new Scanner(System.in);
        for(int i=0;i<4;iPP){
            arr[i]=in.nextInt();
        }
        
        for(int i=0;i<4;iPP){
            System.out.println(arr[i]+"\n");  //
        }
        
    }
}

run result:
clipboard.png
question: why is each number added by 10?

Jun.17,2022

arr [I] +'\ n 'belongs to an int type plus a char. the process is that the char type is first promoted to the int type (the ASCII value of'\ n' is 10), and then added to the int type, which is why the result is 10 more.
println has its own line wrapping feature, so there is no need for\ nline feeds.


'n 'decimal equals 10

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb2ca0-481c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb2ca0-481c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?