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

質問編集履歴

1

ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ

2022/05/17 11:06

投稿

wassan_nikoniko
wassan_nikoniko

スコア9

title CHANGED
@@ -1,1 +1,1 @@
1
- BigDecimal型について
1
+ 自己解決したため記事を落とします
body CHANGED
@@ -1,65 +1,1 @@
1
- ### 前提・実現したいこと
2
- 引数の値で変数を更新したい
3
- Kadai6 のメソッド setdecimal(BigDecimal) は引数 (String) に適用できません
4
- というメッセージが出てしまい、更新できない。
5
-
6
- ### 発生している問題・エラーメッセージ
7
-
8
- ```
9
- Kadai6 のメソッド setdecimal(BigDecimal) は引数 (String) に適用できません
10
- ```
11
-
12
- ### 該当のソースコード
13
-
14
- ```Java
15
- package kadai.pda.k.oonuki6;
16
-
17
- import java.math.BigDecimal;
18
-
19
- public class Kadai6 {
20
- //変数定義
21
- static String str="文字列";
22
- static int i=0;
23
- static BigDecimal decimal=new BigDecimal("3.14");
24
- static long l=2147483648L;
25
- static boolean boo=true;
26
-
27
- //引数をフィールド変数にセットする
28
- public static void setstring(String str1) {
29
- str=str1;
30
- }
31
- public static void setint(int int1) {
32
- i=int1;
33
- }
34
- public static void setdecimal(BigDecimal decimal1) {
35
- decimal=decimal1;
36
- }
37
- public static void setlong(long l1) {
38
- l=l1;
39
- }
40
- public static void setboolean(boolean boo1) {
41
- boo=boo1;
42
- }
43
-
44
-
45
- //フィールド変数を出力する
46
- public static void Output() {
47
- System.out.println(str);
48
- System.out.println(i);
49
- System.out.println(decimal);
50
- System.out.println(l);
51
- System.out.println(boo);
52
- }
53
-
54
- //出力メソッドを呼び出す
55
- public static void main(String[]args) {
56
- setstring("こんにちは");
57
- setint(100);
58
- setdecimal("2.11");
59
- setlong(222223333L);
60
- setboolean(false);
61
- Output();
62
- }
63
- }
64
-
65
- ```
1
+ ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ