0% found this document useful (0 votes)
12 views

Package Import Import Public Class Public Static Void Int

The code defines an integer and long array containing numbers 1 through 10. It uses Java 8 streams to check if the integer array contains the number 4 and prints a message accordingly. It also checks if the long array contains 10 and prints a matching message.

Uploaded by

ripudsudan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Package Import Import Public Class Public Static Void Int

The code defines an integer and long array containing numbers 1 through 10. It uses Java 8 streams to check if the integer array contains the number 4 and prints a message accordingly. It also checks if the long array contains 10 and prints a matching message.

Uploaded by

ripudsudan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

package com.mkyong.

core;

import java.util.stream.IntStream;
import java.util.stream.LongStream;

public class TestDate {

public static void main(String[] args) {

int[] number = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

//Java 8
boolean result = IntStream.of(number).anyMatch(x -> x == 4);

if (result) {
System.out.println("Hello 4");
} else {
System.out.println("Where is number 4?");
}

long[] lNumber = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

boolean result2 = LongStream.of(lNumber).anyMatch(x -> x == 10);

if (result2) {
System.out.println("Hello 10");
} else {
System.out.println("Where is number 10?");
}

You might also like