LoginSignup
0
1

More than 3 years have passed since last update.

Javaメモ(標準クラス)length

Last updated at Posted at 2018-12-07

Java 標準クラス 簡単メモ
 文字数を数えるメソッド
 【length】
  
  使い方:変数 = String変数.length();
  ※変数に落とし込まなくてもそのまま表記することも可能

  //ex)

public static void main(String[] args){
//String変数wordにABCDEFGHIを格納 
String word = "ABCDEFGHI";
  
//int変数countWordに文字数の長さをひっぱってくる
int countWord = word.length();

//int変数を表示
System.out.println(countWord);

//直接表示
System.out.println(word.length());
}

  ※表示結果※
   9
   9

0
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1