質問編集履歴
5
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,52 +1,1 @@
|
|
1
|
-
## 前提・実現したいこと
|
2
|
-
エラー内容がわからず質問したが、28行目の"int" を"String[]"に変更したことで
|
3
|
-
上記エラー文は消えました。次に
|
4
|
-
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
5
|
-
at copy.Main.main(Main.java:24)
|
6
|
-
と、エラーになり、内容の意味を知りたいです。
|
7
|
-
|
8
|
-
コードの問題点もアドバイスが欲しいです。
|
9
|
-
|
10
|
-
```
|
11
|
-
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
12
|
-
型の不一致: String[] から int には変換できません
|
13
|
-
|
14
|
-
at copy.Main.main(Main.java:28)
|
15
|
-
|
16
|
-
```
|
17
|
-
|
18
|
-
### 該当のソースコード
|
19
|
-
|
20
|
-
```ここに言語名を入力
|
21
|
-
import java.util.Scanner;
|
22
|
-
public class Main {
|
23
|
-
|
24
|
-
static String[] getUserPrfofile(int num){
|
25
|
-
String[] data1={"1","技育太郎","東京","男","プログラマー"};
|
26
|
-
String[] data2={"2","技育花子","北海道","女","システムエンジニア"};
|
27
|
-
String[] data3={"3","技育三郎","大阪","男","webエンジニア"};
|
28
|
-
|
29
|
-
if(data1[0]==num) {
|
30
|
-
return total ==data1;
|
31
|
-
}else if(data2[0]==num) {
|
32
|
-
return total =data2;
|
33
|
-
}else if(data3[0]==num) {
|
34
|
-
return total =data3;
|
35
|
-
}else {
|
36
|
-
return null;
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
44
|
-
|
1
|
+
----------------------------------------
|
45
|
-
Scanner scan = new Scanner(System.in);
|
46
|
-
String text = scan.next();
|
47
|
-
int num = Integer.parseInt(text);
|
48
|
-
int total = getUserPrfofile(num);
|
49
|
-
|
50
|
-
System.out.println(total);
|
51
|
-
}
|
52
|
-
}い。
|
4
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,16 +1,52 @@
|
|
1
|
-
##
|
1
|
+
## 前提・実現したいこと
|
2
2
|
エラー内容がわからず質問したが、28行目の"int" を"String[]"に変更したことで
|
3
3
|
上記エラー文は消えました。次に
|
4
|
-
|
4
|
+
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
5
|
+
at copy.Main.main(Main.java:24)
|
6
|
+
と、エラーになり、内容の意味を知りたいです。
|
7
|
+
|
8
|
+
コードの問題点もアドバイスが欲しいです。
|
9
|
+
|
10
|
+
```
|
11
|
+
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
12
|
+
型の不一致: String[] から int には変換できません
|
13
|
+
|
14
|
+
at copy.Main.main(Main.java:28)
|
15
|
+
|
16
|
+
```
|
17
|
+
|
18
|
+
### 該当のソースコード
|
19
|
+
|
20
|
+
```ここに言語名を入力
|
21
|
+
import java.util.Scanner;
|
22
|
+
public class Main {
|
23
|
+
|
24
|
+
static String[] getUserPrfofile(int num){
|
25
|
+
String[] data1={"1","技育太郎","東京","男","プログラマー"};
|
26
|
+
String[] data2={"2","技育花子","北海道","女","システムエンジニア"};
|
27
|
+
String[] data3={"3","技育三郎","大阪","男","webエンジニア"};
|
28
|
+
|
29
|
+
if(data1[0]==num) {
|
30
|
+
return total ==data1;
|
31
|
+
}else if(data2[0]==num) {
|
32
|
+
return total =data2;
|
33
|
+
}else if(data3[0]==num) {
|
34
|
+
return total =data3;
|
35
|
+
}else {
|
36
|
+
return null;
|
5
|
-
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
6
|
-
|
43
|
+
}
|
44
|
+
public static void main(String[] args) {
|
45
|
+
Scanner scan = new Scanner(System.in);
|
46
|
+
String text = scan.next();
|
47
|
+
int num = Integer.parseInt(text);
|
48
|
+
int total = getUserPrfofile(num);
|
49
|
+
|
50
|
+
System.out.println(total);
|
7
|
-
}
|
51
|
+
}
|
8
|
-
|
52
|
+
}い。
|
9
|
-
|
10
|
-
### 試したこと
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
### 補足情報(FW/ツールのバージョンなど)
|
15
|
-
|
16
|
-
ここにより詳細な情報を記載してください。
|
3
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,56 +1,9 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
エラー内容がわからず質問したが、28行目の"int" を"String[]"に変更したことで
|
3
3
|
上記エラー文は消えました。次に
|
4
|
-
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
5
4
|
|
6
|
-
at copy.Main.main(Main.java:24)
|
7
|
-
と、エラーになり、内容の意味を知りたいです。
|
8
|
-
|
9
|
-
コードの問題点もアドバイスが欲しいです。
|
10
|
-
|
11
|
-
```
|
12
|
-
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
13
|
-
型の不一致: String[] から int には変換できません
|
14
|
-
|
15
|
-
at copy.Main.main(Main.java:28)
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
### 該当のソースコード
|
20
|
-
|
21
|
-
```ここに言語名を入力
|
22
|
-
import java.util.Scanner;
|
23
|
-
public class Main {
|
24
|
-
|
25
|
-
static String[] getUserPrfofile(int num){
|
26
|
-
String[] data1={"1","技育太郎","東京","男","プログラマー"};
|
27
|
-
String[] data2={"2","技育花子","北海道","女","システムエンジニア"};
|
28
|
-
String[] data3={"3","技育三郎","大阪","男","webエンジニア"};
|
29
|
-
|
30
|
-
if(data1[0]==num) {
|
31
|
-
return total ==data1;
|
32
|
-
}else if(data2[0]==num) {
|
33
|
-
return total =data2;
|
34
|
-
}else if(data3[0]==num) {
|
35
|
-
return total =data3;
|
36
|
-
}else {
|
37
|
-
return null;
|
38
5
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
6
|
}
|
45
|
-
public static void main(String[] args) {
|
46
|
-
Scanner scan = new Scanner(System.in);
|
47
|
-
String text = scan.next();
|
48
|
-
int num = Integer.parseInt(text);
|
49
|
-
int total = getUserPrfofile(num);
|
50
|
-
|
51
|
-
System.out.println(total);
|
52
|
-
}
|
53
|
-
}
|
54
7
|
}
|
55
8
|
```
|
56
9
|
|
2
要件の変更をしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,33 +1,13 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
|
-
|
2
|
+
エラー内容がわからず質問したが、28行目の"int" を"String[]"に変更したことで
|
3
|
+
上記エラー文は消えました。次に
|
4
|
+
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
3
5
|
|
6
|
+
at copy.Main.main(Main.java:24)
|
4
|
-
|
7
|
+
と、エラーになり、内容の意味を知りたいです。
|
5
8
|
|
6
|
-
|
9
|
+
コードの問題点もアドバイスが欲しいです。
|
7
10
|
|
8
|
-
また、戻り値がnullだった場合、要素の出力ではなく「指定されたIDは見つかりません」と出力してください。
|
9
|
-
|
10
|
-
メソッドの呼び出しの際、実引数は変数 int num を設定してください。
|
11
|
-
|
12
|
-
getUserPrfofileメソッド
|
13
|
-
{"1","技育太郎","東京","男","プログラマー"}
|
14
|
-
|
15
|
-
{"2","技育花子","北海道","女","システムエンジニア"}
|
16
|
-
|
17
|
-
{"3","技育三郎","大阪","男","Webエンジニア"}
|
18
|
-
|
19
|
-
上記の要素を持つ静的配列変数を3つ宣言してください。
|
20
|
-
|
21
|
-
数値型引数をString型変数に型変換し、その後、下記の仕様を満たす条件分岐を実装してください。
|
22
|
-
|
23
|
-
各配列の0番目の値とString型に変換した引数を比較すし、
|
24
|
-
|
25
|
-
比較して一致した場合、一致した配列変数を戻り値としてください。
|
26
|
-
|
27
|
-
また、どの配列とも一致しなかった場合、nullを戻り値としてください。
|
28
|
-
|
29
|
-
### 発生している問題・エラーメッセージ
|
30
|
-
|
31
11
|
```
|
32
12
|
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
33
13
|
型の不一致: String[] から int には変換できません
|
1
タイトルの変更をしました。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
エラー文の意味を知りたいです
|
body
CHANGED
File without changes
|