在java中擷取使用者輸入的的資料,並根據資料執行輸出

來源:互聯網
上載者:User

    因為,沒人要我的原因是我沒有java的基礎,雖然對android瞭解一些,但是,沒有java基礎,有的公司會很難考慮你,鑒於這點,我又開始學java基礎,不圖精深。但求基礎就行。這樣我就能找到一個android的工作了。

import java.util.*;public class Hello{      public static void main(String[] args){          System.out.println("輸入1則輸出我是冠軍。輸入2則什麼都不輸出");           Scanner inputScanner = new Scanner(System.in);\\試用新類Scanner,該類的建構函式可以(接收)使用者的輸入資料             int num = inputScanner.nextInt(); \\試用Scanner類執行個體的 nextInt()方法(擷取)使用者輸入的資料。                 if(num == 1){                       System.out.println("冠軍非你莫屬");                         }         } }

儘管copy去測試demo去吧。這個核心知識點在util包裡的Scanner類的用法及實現。我是純打的,如果運行不通。請留言,咱們一同學習進步

Persist in the end and

never give up

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.