質問編集履歴

1

質問内容の変更

2020/01/20 05:09

投稿

puppycharo
puppycharo

スコア8

test CHANGED
@@ -1 +1 @@
1
- 実行結果にならい、キーボードから英単語を入力し、その単語に用いられている文字を全種類表示するプログラムを作りなさい。文字は、HashSetに登録、一つの単語内に同じ文字が複数使用されてても、一つと
1
+ キーボードから英単語を入力し、HashSetを持ちいて、アルファベット順表記です。
test CHANGED
@@ -1,18 +1,20 @@
1
- ipadで検証できなので確認お願いします。
1
+ 下記のコードを書てみました。よろしくお願いします。
2
2
 
3
3
 
4
4
 
5
- import java.util.*;
5
+ import java.util.*;
6
6
 
7
- public static void main(String[] args) throws IOException {
7
+ public class Main{
8
8
 
9
- InputStreamReder isr=new InputStreamReader(System.ini);
9
+ public static void main(String[] argsthrows IOException {
10
10
 
11
- BufferReader br=new BufferReader(isr);
11
+ InputStreamReder isr=new InputStreamReader(System.ini);
12
12
 
13
- String buf=br.readLine();
13
+ BufferReader br=new BufferReader(isr);
14
14
 
15
+ String buf=br.readLine();
16
+
15
- HashSet<String> hs=new HashSet<String>();
17
+ HashSet<String> hs=new HashSet<String>();
16
18
 
17
19
  while(true){System.out.println("入力してください:");
18
20
 
@@ -22,22 +24,26 @@
22
24
 
23
25
  }
24
26
 
25
- /* String str="apple"; */
27
+ /* String str="apple"; */
26
28
 
27
- String[] buf=str.split("");
29
+ String[] buf=str.split("");
28
30
 
29
- for(int i=0; i<buf.length; i++){
31
+ for(int i=0; i<buf.length; i++){
30
32
 
31
33
  hs.add(buf[i]);
32
34
 
33
- /* System.out.print(" "+buf[i]; */
35
+ /* System.out.print(" "+buf[i]; */
34
36
 
35
37
  }
36
38
 
37
- /* for(String s: hs){System.out.print(s);} */
39
+ /* for(String s: hs){System.out.print(s);} */
38
40
 
39
- List<String> li=ArrayList<String>(hs);
41
+ List<String> li=ArrayList<String>(hs);
40
42
 
41
43
  Collections.sort(li);
42
44
 
43
- for(String t: li){System.out.print(t);}
45
+ for(String t: li){System.out.print(t);}
46
+
47
+ }
48
+
49
+ }