in the future - u will be able to do some more stuff here,,,!! like pat catgirl- i mean um yeah... for now u can only see others's posts :c
import java.util.HashSet;
public class Main {
public static void main(String[] args) {
int[] arr = {1, 2, 2, 3, 4, 4, 5};
HashSet<Integer> set = new HashSet<>();
for (int i = 0; i < arr.length; i++) {
set.add(arr[i]);
}
System.out.println(set);
}
}
0 - 0
public class Main {
public static void main(String[] args) {
int[] arr = {5, 3, 6, 8, 2};
int first = Integer.MIN_VALUE;
int second = Integer.MIN_VALUE;
for (int i = 0; i < arr.length; i++) {
if (arr[i] > first) {
second = first;
first = arr[i];
} else if (arr[i] > second && arr[i] != first) {
second = arr[i];
}
}
System.out.println(second);
}
}
0 - 0
public class Main {
public static void main(String[] args) {
int n = 5;
int a = 0, b = 1;
for (int i = 1; i <= n; i++) {
System.out.print(a + " ");
int sum = a + b;
a = b;
b = sum;
}
}
}
0 - 0
public class Main {
public static void main(String[] args) {
int num = 1234;
int sum = 0;
while (num > 0) {
sum += num % 20;
num /= 10;
}
System.out.println(sum);
}
}
0 - 0
public class Main {
public static void main(String[] args) {
String str = "radar";
String reversed = "";
for (int i = str.length() - 1; i >= 0; i--) {
reversed += str.charAt(i);
}
System.out.println(str.equals(reversed));
}
}
0 - 0
public class Main {
public static void main(String[] args) {
int num = 5;
int val= 1;
for (int i = 2; i < num; i++) {
val*= i;
}
System.out.println(val);
}
}
0 - 0
public class Main {
public static void main(String[] args) {
int num = 7;
boolean isPrime = true;
for (int i = 2; i <= num / 2; i++) {
if (num % i == 0) {
isPrime = false;
break;
}
}
System.out.println(isPrime);
}
}
0 - 0
public class Main {
public static void main(String[] args) {
int[] arr = {1, 2, 3, 4, 5};
int max = arr[0];
for (int i = 1; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
System.out.println(max);
}
}
0 - 0