package javaapplication9; /* ManyNamesHarness.java example code AC Chapin */ // class demonstrating use of classes with arrays // vs arrays of objects public class ManyNamesHarness { public static void main(String[] args) { // a ManyNames contains an array of strings ManyNames m1 = new ManyNames(); System.out.println(m1); // pass in strings to be added to the array inside the ManyNames m1.addName("Butch"); System.out.println(m1); m1.addName("Sue"); m1.addName("Edgar"); System.out.println("Name #2:" + m1.getNthName(2)); // we can do these because the array is public (THIS IS A BAD IDEA) m1.myNames[1] = "Peggy Sue"; System.out.println("Name #0:" + m1.myNames[0]); //m1 = "Bob"; // WRONG, m1 is object (with array of strings) not string //m1[0] = "Bob"; // WRONG m1 is object (with array inside) not array System.out.println("\n" + m1); } }