/** * Author: Josiah Yoder et al. * User: yoder * Class: SE1011-051 * Lesson: Week 8, Day 1 */ import java.util.List; import java.util.Scanner; import java.util.Arrays; import java.util.Collections; //import org.apache.commons.lang.ArrayUtils; public class Example051_9_3 { /* * This is a scratch-paper method */ public static void main(String[] ignored) { // Example051_9_3 example = new Example051_9_3(); // example.testArrayMax(); // Arrays are objects double[] numbers = new double[5]; System.out.println("There are "+numbers.length+" numbers"); System.out.println("The numbers are: "+numbers.toString()); // Tracing example Complex051_9_3 c1 = new Complex051_9_3(1,2); Complex051_9_3 c2 = new Complex051_9_3(3,4); // this // Used to refer to a variable declared // in a class as opposed to the one // declared in the method. // // instance variable -- variable declared // in a class, diferent value for each instance. // // local variable -- variable declared // in a method // // instantiate -- to create an instance of a class // to create object // // an instance of a class -- an object; a copy // of the class that includes its own values // for instance variables // // // class variable -- a variable with a single value // regardless of how many instances there are. // // // // instance methods -- have direct access to instance variables. // Also have access to class variables. // // class methods -- have direct access only to class variables. } /* * This method was written outside of class in an attempt to answer Kevin's question: * * Is it possible to use an Arrays method to find the max or min of an array? * * The answer appears to be "no." What I tried here didn't work. */ public void testArrayMax() { char[] a = {'3', '5', '1', '4', '2'}; List b = Arrays.asList(a); // // Produces run-time exception. // So no, this doesn't work. // char result = ((Character)(Collections.min(b))).charValue(); char result2 = ((Character)(Collections.min(b))).charValue(); System.out.println(result); System.out.println(result2); } }