Cheatography
https://cheatography.com
Adv Integrated Software Dev - Quiz2
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Collections Array
ArrayList<Employee> emplist = new ArrayList<>();
emplist.add(new Employee(123,"Dan1"));
emplist.add(new Employee(1,"Dan2"));
System.out.println(emplist);
Collections.sort(emplist);
|
Collections Array (2) - Input
int numOfEmp = 5;
Scanner input = new Scanner(System.in);
Employee[] empArr = new Employee[numOfEmp];
int id = 101;
String name;
//empArr[0] = new Employee(id,"Sam");
for(int i=0;i<empArr.length;i++) {
System.out.println("Enter employee name");
name = input.nextLine();
empArr[i] = new Employee(id+i,name);
}
|
Collections Array (3) - Input
int[] scores = new int[10];
int score, count =0;
System.out.println("Enter quiz score or enter 999 to quiz");
score = input.nextInt();
while(score != 999) {
scores[count] = score;
++count;
if(count == 10)
score = 999;
else {
System.out.println("Enter quiz score or enter 999 to quiz");
score = input.nextInt();
}
}
System.out.println("number of scores entered " + count);
System.out.println("Scores are");
for(int i=0;i<count;i++)
System.out.print(scores[i] + " ");
|
|