⭐Arraylist.contains() in Java
// creating an Empty Integer ArrayList
ArrayList<Integer> arr = new ArrayList<Integer>(4);
// using add() to initialize values
// [1, 2, 3, 4]
arr.add(1);
arr.add(2);
arr.add(3);
arr.add(4);
// use contains() to check if the element
// 2 exits or not
boolean ans = arr.contains(2);
if (ans)
System.out.println("The list contains 2");
else
System.out.println("The list does not contains 2");
⭐java 삼항연산자
int b = (5 < 4) ? 50 : 40;
int d = (a > b) ? a - b : b - a;
'Bin > 개발일지' 카테고리의 다른 글
2023-12-14, Today I Learned (0) | 2023.12.14 |
---|---|
2023-12-12, Today I Learned (0) | 2023.12.12 |
2023-12-08, Today I Learned (1) | 2023.12.08 |
2023-12-07, Today I Leanred (1) | 2023.12.07 |
2023-12-06, Today I Leanred (2) | 2023.12.06 |