Natalia Smith wrote:But when I tried adding the removeElem method, it refused to compile stating that something was wrong with my variables.
[I'm] very scared of it because I still don't manage to write flawless programs even though I study a lot at home...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Less.java:43: cannot find symbol
symbol : variable smallest
location: class Less
int k = smallest;
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Natalia Smith wrote:Is that what you mean?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
SCJP
Visit my download page
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Natalia Smith wrote:I'm probably missing a return statement in my second method and if you ask like this there should probably also be an "else" around. But I don't know it it would make sense in findMin and if I put it in removeElem, I still need an "if" there of which I don't know what to put in. Maybe something similar as in the "if" from findMin and then declare a new variable, do newVar = zahlen.remove (k); and then return newVar?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
You should note WG’s point, which may explain apparent errors in your code.Winston Gutkowski wrote: . . . Basically, java.util.List provides you with two choices:
1. List.remove(Object) - which removes the first entry equal to 'Object' and returns a boolean (true if an entry was removed; false if not).
and
2. List.remove(int) - which removes the entry at index 'int', and returns its value. . . .
if you pass an int to remove(), the compiler will always call the most appropriate method, which is number 2.
. . .
SCJP
Visit my download page
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |