CISC 124 Lecture 10: 10 -- General Purpose Programming

75 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+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents