package com.myapp.test;
public class VariableArgumentTest {
public static void main(String[] args) {
Auto johnsToy = new Auto("1969", "Fiat", "124 Spider", "5-speed",
"disk brakes");
Auto myTruck = new Auto("1997", "Ford", "Expedition", "Automatic",
"Four-wheel drive", "powerwindows", "power locks",
"air-conditioning", "stereo with cdchanger", "tintedglass");
}
}
class Auto {
public Auto(String year, String make, String model, String... options) {
System.out.println("As Iterator------");
for (String string : options) {
System.out.println(string);
}
System.out.println("As Array---------");
for (int i = 0; i < options.length; i++) {
System.out.println(options[i]);
}
}
public Auto() {
}
}
public class VariableArgumentTest {
public static void main(String[] args) {
Auto johnsToy = new Auto("1969", "Fiat", "124 Spider", "5-speed",
"disk brakes");
Auto myTruck = new Auto("1997", "Ford", "Expedition", "Automatic",
"Four-wheel drive", "powerwindows", "power locks",
"air-conditioning", "stereo with cdchanger", "tintedglass");
}
}
class Auto {
public Auto(String year, String make, String model, String... options) {
System.out.println("As Iterator------");
for (String string : options) {
System.out.println(string);
}
System.out.println("As Array---------");
for (int i = 0; i < options.length; i++) {
System.out.println(options[i]);
}
}
public Auto() {
}
}