CISC 124 Lecture 10: 10 -- General Purpose Programming

74 views1 pages

Document Summary

Will not be asked to write java generics on assignments, quizzes or the final. Arraylist lst = new arraylist(); lst. add(apple); lst. add(0, bannana); //adds bannana to the first element lst. remove(1); //removes element in position 1 (apple) Arraylist strlst = newarraylist()>//= list of string strlst. add(this); char firstchar = strlst. get(0). charat(0); // no need for a cast str. add(new integer(42)); //compile-time error. Good to import java. util* which comparable is in. Can write a class (like employee) that implements comparable. A comparator is another way to specify a comparison method. Separate object, not a modification to the class. To declare: public interface comparator { int compare(t o1, t o2); // works like compareto. It"s convenient to modify the sourcee of your class.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents