Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Last active August 6, 2024 07:11
Show Gist options
  • Save sunmeat/251fbb90c5b087da8ffe to your computer and use it in GitHub Desktop.
Save sunmeat/251fbb90c5b087da8ffe to your computer and use it in GitHub Desktop.
var args with errors!
package com.alex.methods;
class VarArgsBadExample {
public static void va(int a, double b, String... s) {
// в методе могут быть другие параметры, кроме ...
}
public static void va(int... v) {
// вполне обычный метод
}
public static void va(int a, int... v) {
// ошибки нет, но вызвать такой метод не получится - ambigious call
}
public static void va(int a, double b, String... v, boolean c) {
// ... в середине сигнатуры не допускается!
}
public static void va(int... i, String... s) {
// несколько ... не допускается!
}
public static void main(String[] args) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment