Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe17ffe

Browse files
committed
Replace Stream.ofRange with IntStream.range
1 parent 60c004b commit fe17ffe

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎app/src/main/java/com/annimon/java8streamexample/MainActivity.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.widget.SeekBar;
99
import android.widget.Spinner;
1010
import android.widget.Toast;
11+
import com.annimon.stream.IntStream;
1112
import com.annimon.stream.Stream;
1213
import java.util.Random;
1314

@@ -113,8 +114,8 @@ private void action(String action) {
113114
});
114115
break;
115116
case "add index":
116-
stream = Stream.ofRange(0, mAdapter.getCount())
117-
.map(i -> String.format("%d. %s", i+1, mAdapter.getItem(i).getWord()))
117+
stream = IntStream.range(0, mAdapter.getCount())
118+
.mapToObj(i -> String.format("%d. %s", i+1, mAdapter.getItem(i).getWord()))
118119
.map(str -> new Word(str, ""));
119120
break;
120121
case "skip %N":
@@ -125,8 +126,8 @@ private void action(String action) {
125126
break;
126127
case "group":
127128
// Show 5 words by each group
128-
stream = Stream.ofRange('a', 'z'+1)
129-
.map(i -> String.valueOf((char) i.shortValue()))
129+
stream = IntStream.range('a', 'z'+1)
130+
.mapToObj(i -> String.valueOf((char) i))
130131
.flatMap(s -> Stream.of(mAdapter.getWords())
131132
.filter(w -> w.getWord().startsWith(s))
132133
.limit(5))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /