第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在第 11 行中,我該如何制作,這樣我就不需要使用這么多空格

在第 11 行中,我該如何制作,這樣我就不需要使用這么多空格

慕斯王 2024-01-05 14:59:54
如何在不更改格式的情況下刪除所有空格以及最好的選擇是什么,如果是的話我會(huì)使用 System.out.printf(); 或其他一些指令。請(qǐng)用java而不是C++回復(fù)。我真的很感激任何提供幫助的人,并且很樂意感謝他們幫助我解決自己的問題。public class WorldPopulation{    //main string    public static void main(String[] args) {             //prints title             System.out.println(" This is a estimate of world population growth within 300 year time span. ");            //prints number value            System.out.println("                       Numbers are in millions");            //number of rows and columns            final int ROWS = 6;            final int COLUMNS = 7;            //population numbers array            int [] [] populations =                {                        {106, 107, 111, 133, 221, 767, 1766},                        {502, 635, 809, 947, 1402, 3634, 5268},                        {2, 2, 2, 6, 13, 30, 46},                        {163, 203, 276, 408, 547, 729, 628},                        {2, 7, 26, 82, 172, 307, 392},                        {16, 24, 3, 74, 167, 511, 809}                };            //continents array            String[] continents =                {                        "Africa",                        "Asia",                        "Australia",                        "Europe",                        "North America",                        "South America"                };            //prints the years used in the estimation                   System.out.println("                Year 1750 1800 1850 1900 1950 2000 2050");            //print population data            for (int i = 0; i < ROWS; i++)    {                       //print i'th row                   System.out.printf("%20s", continents[i]);            //prints the columns and the rows            for (int j = 0; j < COLUMNS; j++) {                System.out.printf("%5d", populations [i] [j]);            }                System.out.println(); //start new line at end of row        }
查看完整描述

1 回答

?
慕容3067478

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊

你可以這樣做:

System.out.format("%15s%s", "", "Test");

這里有一個(gè)長(zhǎng)度為 15 的字符串,后面跟著一個(gè)未定義的字符串。由于第一個(gè)格式化的字符串是空字符串,因此將打印 15 個(gè)空格。


查看完整回答
反對(duì) 回復(fù) 2024-01-05
  • 1 回答
  • 0 關(guān)注
  • 114 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)