CompSci 100E5.1What can you put into an ArrayList?ÿ Anything that derives from Object String, ArrayList, Counter, … int, double, char, boolean, …NO!!!ÿ What can we do if want a collection of int values Put an upper bound on the count and use arrayint index = 0;int[] a = new int[HUGE_NUMBER];while (…) {if (condition()){a[index++] = value;}}CompSci 100E5.2What can you put into an ArrayList?ÿ Use a wrapper class (see java.lang.*) int, double, char, boolean, … Integer, Double, Character, Boolean,ArrayList list = new ArrayList();while (…) {if (condition()){list.add(new Integer(value));}}int[]a=newint[list.size()];for(intk=0;k<list.size();k++){a[k] = ( (Integer) list.get(k) ).intValue();}CompSci 100E5.3What is a char?ÿ Differences between unicode and ASCII Why is unicode used? Why should we care? What should we know? How many of the details are important?ÿ A char value can be treated like a 16 bit int value Add integer to it, cast back to char Subtract character from it, get int backcounters[‘z’ - s.charAt(k)]++; Anatomy of the statement above??CompSci 100E5.4Lydia Kavrakiÿ Awards Grace Murray Hopper Brilliant 10"I like to work on problems that will generally improve the quality of our life," What's the thing you love most about science?“Working with students and interacting with people from diverse intellectual backgrounds. Discovery and the challenge of solving a tough problem, especially when it can really affect the quality of our lives. I find the whole process
View Full Document