intでHashSetを初期化しようとしましたが、動作しませんでした。整数をHashSetコンストラクタに送信できません
public class HelloWorld
{
// arguments are passed using the text field below this editor
public static void main(String[] args)
{
Set<Integer> a = new HashSet<Integer>(123456);
a.add(55);
System.out.println(a);
}
}
出力: [55]
なぜそれが起こっているとどのように私はHashSetのコンストラクタに単一のintを送ることができますか?
ありがとうございます!
「新しいHashSet(123456)」はどうすると思いますか?あなたはJavadocを読んだことがありますか? –
最初の要素として123456を追加しますか? –
Javadocを読んでください。 –