@@ -0,0 +1,1785 @@
+/*%0A * #%25L%0A * ImageJ interactive debugging tutorials.%0A * %25%25%0A * Copyright (C) 2009 - 2015 Board of Regents of the University of Wisconsin-Madison%0A * %25%25%0A * To the extent possible under law, the ImageJ developers have waived%0A * all copyright and related or neighboring rights to this tutorial code.%0A * %0A * See the CC0 1.0 Universal license for details:%0A * http://creativecommons.org/publicdomain/zero/1.0/%0A * #L%25%0A */%0A%0Apackage net.imagej.trouble.visible;%0A%0Aimport java.util.List;%0A%0Aimport net.imagej.trouble.hidden.ObjectMaker;%0A%0A/**%0A * Exercise 2: Using the Expression Window in the Debug perspective.%0A *%0A * @author Mark Hiner %3Chinerm@gmail.com%3E%0A */%0Apublic class E2EffectiveExpressions %7B%0A%0A%09public static void main(final String... args) %7B%0A%09%09// Let's make a list of 100000 objects%0A%09%09final List%3CObject%3E myList = ObjectMaker.getList(100000);%0A%0A%09%09// Now let's process some objects from our list%0A%0A%09%09// Process first object%0A%09%09processElementAtIndex(myList, 0);%0A%0A%09%09// Process middle object%0A%09%09processElementAtIndex(myList, 100000 / 2);%0A%0A%09%09// Process last object%0A%09%09processElementAtIndex(myList, 100000 - 1);%0A%09%7D%0A%0A%09private static void processElementAtIndex(final List%3CObject%3E list,%0A%09%09final int index)%0A%09%7B%0A%09%09// First let's check our method arguments to see if they're valid%0A%09%09if (index %3C 0 %7C%7C index %3E= list.size()) %7B%0A%09%09%09// The fact that this method is already doing input validation makes%0A%09%09%09// debugging very easy.%0A%09%09%09// The next line of code will only be executed if a problem is detected,%0A%09%09%09// so it's%0A%09%09%09// a great place to set a breakpoint.%0A%09%09%09throw new IllegalArgumentException(%0A%09%09%09%09%22If you don't mind, I would prefer not to process your object...%22);%0A%09%09%7D%0A%0A%09%09// OK now we can process the argument.%0A%09%09// ... just kidding, I'm totally going to delete your precious objects.%0A%09%09list.set(index, null);%0A%09%7D%0A%7D%0A

Create Exercise 2