Convert varargs to an array : Varargs « Language Basics « Java

Convert varargs to an array


public class Main {
  public static void main(String[] args) {
    printMessage("H", "Y", ", ", "how ", "are ", "you", "?");

  public static void printMessage(String... messages) {
    String[] copiedMessage = messages;
    for (int i = 0; i < messages.length; i++) {


Related examples in the same category

1.VarArgs Example
2.Create a method that accept varargs in Java
3.Varargs, overloading, and ambiguity.
4.Old style: Use an array to pass a variable number of argumentsOld style: Use an array to pass a variable number of arguments
5.Demonstrate variable length arguments. Demonstrate variable length arguments.
6.Use varargs with standard arguments. Use varargs with standard arguments.
7.Varargs and overloading.Varargs and overloading.
8.Java Varargs TesterJava Varargs Tester
9.Java enum and varargs
10.Java varargs: Iterating Over Variable Length Argument Lists
11.New parameter for main method