Somme des éléments d'un tableau java
int[] nb = {1,2,3,4,5,6,7,8,9};
int somme = java.util.stream.IntStream.of(nb).sum();
System.out.println(somme); //45
Somme des éléments d'un tableau java
int[] nb = {1,2,3,4,5,6,7,8,9};
int somme = java.util.stream.IntStream.of(nb).sum();
System.out.println(somme); //45
Somme des éléments d'un tableau java
import java.util.*;
public class CompareTableaux
{
public static void main(String[] args)
{
String[]
arr1 = { "2", "3", "5", "7", "11" },
arr2 = { "2", "4", "6", "8", "11", "12" };
List<String> l1 = Arrays.asList(arr1);
List<String> l2 = Arrays.asList(arr2);
HashSet<String> communs = new HashSet<String>(l1);
communs.retainAll(l2);
HashSet<String> non_communs = new HashSet<String>(l1);
non_communs.addAll(l2);
non_communs.removeAll(communs);
System.out.println(communs); // [11, 2]
System.out.println(non_communs); // [12, 3, 4, 5, 6, 7, 8]
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us