public class BiggestNumber {
public static void main(String[] args) {
int a = 50, b = 20, c = 40;
if (a > b && a > c)
System.out.println("a is Biggest number");
else if (b > c)
System.out.println("b is Biggest number");
else
System.out.println("c is Biggest number");
}
}
public static void main(String[] args) {
int a = 50, b = 20, c = 40;
if (a > b && a > c)
System.out.println("a is Biggest number");
else if (b > c)
System.out.println("b is Biggest number");
else
System.out.println("c is Biggest number");
}
}
Java Hyd Team
public class BiggestNumber { public static void main(String[] args) { int a = 50, b = 20, c = 40; if (a > b && a > c) System.out.println("a is Biggest number"); else if (b > c) System.out.println("b…
Can use ternary operator also that will be just one line code
public class DuplicateElementsInArray {
public static void main(String[] args) {
//Initialize array
int [] arr = new int [] {1, 2, 3, 4, 2, 7, 8, 8, 3};
System.out.println("Duplicate elements in given array: ");
//Searches for duplicate element
for(int i = 0; i < arr.length; i++) {
for(int j = i + 1; j < arr.length; j++) {
if(arr[i] == arr[j])
System.out.println(arr[j]);
}
}
}
}
public static void main(String[] args) {
//Initialize array
int [] arr = new int [] {1, 2, 3, 4, 2, 7, 8, 8, 3};
System.out.println("Duplicate elements in given array: ");
//Searches for duplicate element
for(int i = 0; i < arr.length; i++) {
for(int j = i + 1; j < arr.length; j++) {
if(arr[i] == arr[j])
System.out.println(arr[j]);
}
}
}
}
Java Hyd Team
public class DuplicateElementsInArray { public static void main(String[] args) { //Initialize array int [] arr = new int [] {1, 2, 3, 4, 2, 7, 8, 8, 3}; System.out.println("Duplicate elements in given array: "); …
public class DuplicateFinder {
public static void main(String[] args) {
int[] arr = {1,2,3,4,5,3,4,7};
for (int i = 0; i < arr.length; i++) {
int element = arr[i];
boolean found = false;
for (int j = 0; j < i; j++) {
found = (arr[i] == arr[j]) ? true : false;
if (found) {
System.out.println("Duplicate element: " + element);
break;
}
}
}
}
}
Same question using ternary operator
public static void main(String[] args) {
int[] arr = {1,2,3,4,5,3,4,7};
for (int i = 0; i < arr.length; i++) {
int element = arr[i];
boolean found = false;
for (int j = 0; j < i; j++) {
found = (arr[i] == arr[j]) ? true : false;
if (found) {
System.out.println("Duplicate element: " + element);
break;
}
}
}
}
}
Same question using ternary operator
Java Hyd Team
Get ready with strings concepts , jsp.
👆👆 strings , inheritance concepts only they asked today 😁😁
Soon we are going to open our tech window you can get access to immense of opportunities with this and bunch of freelance projects also 😊😊