Pin It

How to use Variable Arguments Parameter List in a Java program ?.

A simple Java program demonstrating the use of Variable Arguments Parameter List

package com.hubberspot.objects.example;

class VarArgument
{
  void display(String message, String...names)
  {
    for(String name : names)
      System.out.println(message + name);
  }
}

public class VarArgsDemo
{
  public static void main(String[] args)
  {
     VarArgument var = new VarArgument();
     var.display("Hello " , "Hubberspot");
     var.display("Welcome ", "Jonty", "Michelle", "Tsotsobe");
 }
}


Output of the program :



Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot