質問

私は自分の方法で、適切なオブジェクトとして配列を使用しての代わりに、アレイ、アレイとArrayUtilsなどのヘルパークラスに依存する上でこちらのページを書かれています。

ints.sort(); // instead of Arrays.sort(ints);
// instead of int[] onemore = ArrayUtils.add(ints, 8);
int[] onemore = ints.add(8); 

私はこの考えと最初ではないが、私はトラブルの前にこのことについて書かれている他の人を探してを持っていたと確信しています。

誰がこのトピックに関するいくつかの参照で私を助けることができますか?

あなたは1を持っている場合、これは悪いアイデアか良いアイデアである理由についての参照を持っている場合は、コメントを追加できますか?

リンクを削除。メインポイントを追加する

このプロジェクトは、コイン

の考えから、次の
OVERVIEW
Provide a two sentence or shorter description of these five aspects of the feature:
FEATURE SUMMARY: Should be suitable as a summary in a language tutorial.

独自の方法ではなく、値を持つオブジェクトとして扱うアレイは、ヘルパーメソッドに渡されます。これは、より自然なコーディングにつながると方法により即時性を提供します。例えばコード補完を介して

MAJOR ADVANTAGE: What makes the proposal a favorable change?

これは、既に利用可能と書かれたメソッドをサポートする、アレイにオブジェクト指向プログラミングをもたらす。

MAJOR BENEFIT: Why is the platform better if the proposal is adopted?

アレイのオブジェクト志向の一貫。

MAJOR DISADVANTAGE: There is always a cost.

誰かがそれを書いて、それをテストする必要があります。

ALTERNATIVES: Can the benefits and advantages be had some way without a language change?

ヘルパーメソッドを呼び出します。

EXAMPLES
Show us the code!
SIMPLE EXAMPLE: Show the simplest possible program utilizing the new feature.

int[] ints = {5,4,3,2,1};
ints.sort(); // instead of Arrays.sort(ints);
int pos = ints.indexOf(5); // instead of Arrays.asList(ints).indexOf(5); or ArraysUtils.indexOf(ints, 5);
ints.reverse(); // instead of Arrays.reverse(ints);
Array array = ints; // cast to super class.
int length = array.getLength(); // instead of Array.getLength(array);
Object n = array.get(3); // instead of Array.get(array, 3);
array.set(3, 7); // instead of Array.
Object obj = array;
System.out.println(obj); // prints [5,4,7,2,1] instead of having to if (obj instanceof int[]) System.out.println(Array.toString((int[]) obj)); else if (....)
  

高度な例:機能の表示の高度な使い方(S)

int[] ints = {5,4,3,2,1};
int[] ints2 = ints.copyOf(2);
int[] ints3 = ints.subArray(2,4);
ints.sort(myComparator);
List<Integer> list = ints.asList();
Set<Integer> set = ints.asSet();
long total = ints.sum();
double avg = int.average();
int max = ints.max();
int max2 = ints.max(myComparator);
http://commons.apache.org/lang/api/org/apache/commons/lang/ArrayUtils.html
int[] onemore = ints.add(8); // instead of ArrayUtils.add(ints, 8);
int[] moreInts = ints.addAll(ints2); // instead of ArraysUtils.addAll(ints, ints2);
int[] oneless = int.remove(3); // instead of ArrayUtils.remove(ints, 3);
Integer[] integers = int.toObject();
int[] intsAgain = integers.toPrimitive();

DETAILS
SPECIFICATION: Describe how the proposal affects the grammar, type system, and meaning of expressions and statements in the Java Programming Language as well as any other known impacts.

このようなjava.lang.Arrayなどのクラスは、すべてのアレイの親として追加する必要があります。特定のint型のためのサブクラス[]、ブール[]も必要になることがあります。 文法は劇的に異なることはないはずです。

COMPILATION: How would the feature be compiled to class files? Show how the simple and advanced examples would be compiled. Compilation can be expressed as at least one of a desugaring to existing source constructs and a translation down to bytecode. If a new bytecode is used or the semantics of an existing bytecode are changed, describe those changes, including how they impact verification. Also discuss any new class file attributes that are introduced. Note that there are many downstream tools that consume class files and that they may to be updated to support the proposal!
それが今であるとして

アレイ用の新しい親を使用することができる提供では、コンパイルは同じになります。しかし、それは配列が異なるスーパークラスを持っていることを受け入れる必要があるだろうJVMです。

TESTING: How can the feature be tested?

新しいメソッドはヘルパーメソッドと同じことを行うか確認してください。 (確かに、彼らはちょうど同じヘルパーメソッドを呼び出す場合、簡単なはずです)。

LIBRARY SUPPORT: Are any supporting libraries needed for the feature?

このは、rt.jarのに追加する必要があります。

REFLECTIVE APIS: Do any of the various and sundry reflection APIs need to be updated? This list of reflective APIs includes but is not limited to core reflection (java.lang.Class and java.lang.reflect.*), javax.lang.model.*, the doclet API, and JPDA.

配列のスーパークラスではなく、java.lang.Object上位のjava.lang.Arrayなどを返却する必要があります。しかし、再び、これはJVMの変更ではなくrt.jarのコードであってもよい。

OTHER CHANGES: Do any other parts of the platform need be updated too? Possibilities include but are not limited to JNI, serialization, and output of the javadoc tool.

の変化は、Javadocを反映すべきである。

MIGRATION: Sketch how a code base could be converted, manually or automatically, to use the new feature.

;

(引数)をarray.xxxするArrays.xxx(アレイ、引数)への呼び出しを置き換えます

COMPATIBILITY
BREAKING CHANGES: Are any previously valid programs now invalid? If so, list one.

は、すべての方法が取られた場合に変更されるのhashCode()とequals()を呼び出します。

;これは、むしろをArrays.hashCode()またはをArrays.equals()を呼び出すよりも、これらの方法を残すことができた場合には受け入れられないかもしれ
EXISTING PROGRAMS: How do source and class files of earlier platform versions interact with the feature? Can any new overloadings occur? Can any new overriding occur?

はありません。

REFERENCES
EXISTING BUGS: Please include a list of any existing Sun bug ids related to this proposal.

これは、私は、バグレポートや他の参照

のヘルプを探していますものです
役に立ちましたか?

解決

私はあなたの代わりに、さまざまなコレクションクラスに見てください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top