-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion59.java
More file actions
48 lines (39 loc) · 1.01 KB
/
Copy pathQuestion59.java
File metadata and controls
48 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Question 59:
Fill from Index to End with given Value based on user
Write a program to fill an array from index 2 to the endIndex 4 with the
constant value 10 in the array
{1, 2, 3, 4, 5, 6}.
Output: {1, 2, 10, 10, 10, 6}
*/
package com.nit_51_60;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Question59 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter from Index Number ");
int i1 = sc.nextInt();
System.out.println("Enter to Index number ");
int i2=sc.nextInt();
int arr[] = {1, 2, 3, 4, 5, 6};
for(int i=0;i<arr.length;i++)
{
if(i>=i1 && i <=i2)
{
arr[i]=10;
}
}
// for(int i=0;i<arr.length;i++)
// {
// System.out.println(arr[i]);
// }
//
IntStream stream = Arrays.stream(arr);
stream.forEach(System.out::println);
}
}