Java: non-static method cannot be referenced from a static context / ArrayList -




hello i'm trying resolve 1 exercise. i've got list , have create private method returns new list removed every 3rd argument. i've created method , body of it, have no idea should write lines of code " arraylist inputlist = new arraylist(arrays.aslist(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));" , " arraylist modifiedlist = removeeverythirdelement(inputlist);"

i cannot write in main method because it's static , void method , doesn't compile. should write special private method returns or can write these lines in class, without method?

public static void main(string[] args) { }      arraylist<integer> inputlist = new arraylist(arrays.aslist(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));     arraylist<integer> modifiedlist = removeeverythirdelement(inputlist);   private arraylist<integer> removeeverythirdelement(arraylist<integer> inputlist){     for(integer : inputlist) {         if (i % 3 == 0) {             inputlist.remove(i);         }     }     return modifiedlist; } 

}





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -