java語言基礎

來源:互聯網
上載者:User

標籤:

1.出錯誤資訊與調試資訊

out是標準調試資訊的輸出資料流

err是標準錯誤資訊輸出資料流

該方法的聲明如下:

public void println(String x)

上面的參數說明   x:被輸出到控制台的字串

public class test {    public static void main(String[] args) {        System.out.println("main()方法開始運行了");        System.err.println("在運行期間手動輸出一個錯誤資訊:");        System.err.println("\t該軟體沒有買保險,請注意安全");        System.out.println("PrintErrorAndDebug.main()");        System.out.println("main()方法運行結束");    }}

2.使用nextLine()方法從輸入資料流中擷取使用者輸入的整行文本字串,該方法的聲明如下:

public String nextLine()

該方法從掃描器封裝的輸入資料流中擷取一行文本字串作為方法的傳回值

import java.util.Scanner;public class test{    public static void main(String[] args){        Scanner scanner=new Scanner(System.in);        System.out.println("請輸入你的社會安全號碼:");        String line=scanner.nextLine();        System.out.println("原來你的社會安全號碼是:"+line.length()+"位元字的啊");    }}

3.

java語言基礎

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.