編集の要約なし
編集の要約なし
4行目: 4行目:
指定位置の1文字をcharで知らせます。指定位置は 0 から数えます。
指定位置の1文字をcharで知らせます。指定位置は 0 から数えます。


  int num = Integer.parse(input);
  String s1 = "Java and Python and C++.";
char char = text.charAt(num);
  System.out.println(s1.charAt(11));
  System.out.println("Char at " + num + " is " + char);

2019年6月9日 (日) 12:32時点における版

(String).charAt [1]
public char charAt(int index)

指定位置の1文字をcharで知らせます。指定位置は 0 から数えます。

String s1 = "Java and Python and C++.";
System.out.println(s1.charAt(11));