





























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In this course, Introduction to Programming in Java, we learned all programming concepts and implement them in java. Key points in these lecture slides are: Classes and Objects, Solutions, Minvalue, Minindex, Values, Array Index, Array Value, Popular Issues, Indexes, Print
Typology: Slides
1 / 69
This page cannot be seen from the preview
Don't miss anything!






























































public static int getSecondMinIndex(int[] values) {
int secondIdx = -1;int minIdx= getMinIndex(values); for(int i=0; i<values.length; i++) {
if (i == minIdx)
continue; if (secondIdx == -1 ||
values[i] < values[secondIdx])^ secondIdx = i;
} return secondIdx; } •^ What happens if values = {0}? values = {0, 0}? values = {0,1}?
// 99
int min = 0;for (int i = 0; i < vals.length; i++) {^ if (vals[i] < min) {
min = vals[i] } } }
vals = {1,2,3}
min = Integer.MAX_VALUE
vals[0]Docsity.com
if (i == minIdx) continue;if (vals[i] < vals[secondIdx])
secondIdx = i;
System.out.println(“cur min: ”
System.out.println(“new min: ” + vals[i]);minVal = vals[i]; } }
Docsity.com
= 0; i < vals.length; i++) { if^
(vals[i] < vals[minIdx]) {
// little baby alex String nameAlex;double weightAlex; // little baby david String nameDavid;double weightDavid;
// little baby alex String nameAlex;double weightAlex; // little baby david String nameDavid;double weightDavid; // little baby david String nameDavid2;double weightDavid2;
Docsity.com