...

x

Write a program **to identify the nearest number of a given number from a given list of numbers**.

Input (List) | int |
---|---|

[1, 2, 23, 45, 67, 87, 4, 10, 14], 7 | 4 |

[12, 45, 32, 56, 87, 94, 33, 45, 78], 110 | 94 |

[7, 44, 67, 8, 34, 54, 67, 89], 1 | 7 |

```
class FindTheNearestNumber
```{ public static void main(String s[])

{

List input = new ArrayList();

input.add(23);

input.add(12);

input.add(45);

input.add(67);

input.add(43);

input.add(89);

input.add(100);

System.out.println("The nearest number of 55 is : " + getNearestNumber(input, 55));

}

private static int getNearestNumber(List<Integer> input, int number) {

//Write code here to identify the nearest number of a given number from a given list of numbers

}

}

Topic: Java ArrayList

0

Wrong
Score more than 2 points