teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

*間違いprofile.lenth → 正しくはprofile.length

2019/11/19 05:29

投稿

退会済みユーザー
answer CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  //*間違いprofile.lenth → 正しくはprofile.length
24
24
  //*変更 iの上限を要素数に合わせる
25
- for(int i=0; i<profile.lenth; i++){
25
+ for(int i=0; i<profile.length; i++){
26
26
  System.out.print(profile[i]);
27
27
  }
28
28
  }

2

間違いprofile.lenth → 正しくはprofile.length

2019/11/19 05:29

投稿

退会済みユーザー
answer CHANGED
@@ -20,6 +20,7 @@
20
20
  //*追加 getUserProfileメソッドからの戻り値を代入
21
21
  String[] profile=getUserProfile(1);
22
22
 
23
+ //*間違いprofile.lenth → 正しくはprofile.length
23
24
  //*変更 iの上限を要素数に合わせる
24
25
  for(int i=0; i<profile.lenth; i++){
25
26
  System.out.print(profile[i]);

1

mainメソッドにてString[] profile=getUserProfile(1);

2019/11/19 05:20

投稿

退会済みユーザー
answer CHANGED
@@ -1,11 +1,13 @@
1
+ //ご指摘どおり型変換は必要ありませんでした。↓2行目間違いです。
1
2
  int型をString型に型変換することで解決しました。
2
3
 
4
+
3
5
  public class Main {
4
6
  // *変更 getUserProfile(int num)←ここ{
5
7
  static String[] getUserProfile(int num){
6
8
  String[] profile0 ={"1","太郎","東京","男","プログラマー"};
7
9
 
8
- //*追加 intの引数ををString型に変換
10
+ //*型変換の必要はありませんでした。↓必要なし。
9
11
  String strnum=String.valueOf(num);
10
12
 
11
13