Last active
August 6, 2024 07:11
-
-
Save sunmeat/251fbb90c5b087da8ffe to your computer and use it in GitHub Desktop.
var args with errors!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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