anoterCode
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Amazon {
|
||||
public static void main(String[] args) {
|
||||
int x = 0;
|
||||
int[] ar = { 3, 4, 4, 4, 3, 3, 3, 3, 6, 6, 6, 6, 1, 1, 1, 1, 9 };
|
||||
ArrayList<Integer> al = new ArrayList<>();
|
||||
for(int i : ar){
|
||||
al.add(ar[i]);
|
||||
if(!al.contains(ar[i])){
|
||||
al.add(ar[i]);
|
||||
++x;
|
||||
for(int j = i + 1; j < ar.length; j++){
|
||||
if(ar[i] == ar[j]){
|
||||
x++;
|
||||
}
|
||||
}
|
||||
System.out.println(ar[i]);
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
public class Construct {
|
||||
int year;
|
||||
String model;
|
||||
String make;
|
||||
|
||||
public Construct() {
|
||||
|
||||
}
|
||||
|
||||
public void carMake(String make, String model, int year) {
|
||||
this.model = model;
|
||||
this.make = make;
|
||||
this.year = year;
|
||||
System.out.println("My car by " + year + " is " + make + " - " + model);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Construct car = new Construct();
|
||||
car.carMake("Audi", "RS6", 2025);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user