劉任昌Java套件Scanner,方法length(),charAt()

Java程式碼

import java.util.Scanner; /*開啟套件package util=utility用途,Scanner掃描器*/
/*蔡英文utility industry=公用事業產業,電力,自來水,效用=utility */
class MyClass {
  public static void main(String[] args) {
    String a, b="";                           /*定義字串a,b */
    Scanner myObj = new Scanner(System.in);   /*建構掃描物件*/
    System.out.print("輸入: ");
    a = myObj.nextLine();                     /*輸入文字nextLine到變數a */
    System.out.println("長度: " + a.length());/*輸出字串長度length() */
    for (int i = 0; i < a.length(); i++)      /*迴圈 */
        b = a.charAt(i) + b;                  /*a字元順序放到b前面*/
      System.out.println("輸出: "+ b);
    }
}

Visual Studio Code程式開發環境

Java類別Classes/物件Objects

每一個類別或物件,包含屬性attributes與方法method。

JavaScript將輸入的字串顛倒輸出

輸入字串:

JavaScript將輸入的字串顛倒輸出程式碼

<p>輸入字串:<input type="text" len="50" id="in"></p>
<p><input type="button" value="執行JavaScript" onclick="f()"></p>
<p id="out"></p>
<script>
function f(){
  var a = document.getElementById("in").value;/*取得id=in的文字*/
  var b = "長度是:" + a.length + ",反串是: ";
  var c = "";
  for (var i = 0; i < a.length; i++)
    c = a.slice(i,i+1) + c ;
  b = b + c;
  document.getElementById("out").innerHTML = b;
}
</script>

說明影片194

留言

  1. https://xdrcfvghyujiok8945656.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  2. https://d11150115.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  3. https://cindy-javascript.blogspot.com/2022/12/blog-post_29.html

    回覆刪除
  4. https://yuzcc28.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  5. https://d11150116.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  6. https://lihtml-css-javascript-java.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  7. https://iuytjhg5261.blogspot.com/2022/12/blog-post_29.html

    回覆刪除
  8. https://enchenghu0905.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  9. https://d11150108.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  10. https://www.blogger.com/blog/post/edit/preview/5444106583314177344/5391348772692489455

    回覆刪除
  11. https://d11150114.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  12. https://tgyhjikolujik2554.blogspot.com/2022/12/javascannerlengthcharat.html

    回覆刪除
  13. https://cindy-javascript.blogspot.com/2023/01/javascannerlengthcharat.html

    回覆刪除
  14. https://d11150112.blogspot.com/2023/01/javascannerlengthcharat.html

    回覆刪除
  15. https://643gjeytfru4312.blogspot.com/2023/01/javascannerlengthcharat.html

    回覆刪除
  16. https://iuytjhg5261.blogspot.com/2023/01/h1bordersolid-8px-purple-javascript.html

    回覆刪除
  17. https://danny1219.blogspot.com/2023/01/d11117226javascript.html

    回覆刪除
  18. https://steven0918.blogspot.com/2023/01/d11117219javascript.html

    回覆刪除
  19. 作者已經移除這則留言。

    回覆刪除
  20. https://www.blogger.com/blog/post/edit/8098460896125661899/4167256795233737060

    回覆刪除
  21. https://zhangzheming920304.blogspot.com/2023/01/javalengthcharat.html

    回覆刪除
  22. 作者已經移除這則留言。

    回覆刪除
  23. 作者已經移除這則留言。

    回覆刪除
  24. 作者已經移除這則留言。

    回覆刪除
  25. https://htm-css-javascript-java.blogspot.com/2023/01/d11117326javascript.html

    回覆刪除
  26. https://ericlian-pc.blogspot.com/2023/01/d11117234javascriptjs-codejava.html

    回覆刪除
  27. https://sophie0930307.blogspot.com/2023/01/d11117233javascript.html

    回覆刪除
  28. https://sherryd11117110.blogspot.com/2023/01/d11117110javascript-js-cobejava.html

    回覆刪除
  29. https://www.blogger.com/blog/post/edit/5577572625675926264/7320583077753022806

    回覆刪除
  30. https://kai1115.blogspot.com/2022/12/javalengthcharatexcellenmid.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌對照Python與JavaScript指令

劉任昌Python集合set清單list元組tuple字典dictionary

劉任昌python, input, str, float