CSE 115 Lecture 27: 04.01.16 lecture notes

81 views4 pages

Document Summary

//a method that takes an arraylist as argument and returns false if the first string has length 5, false otherwise. Arraylist is empty, return false public boolean firststringoflength5(array list) { if (list == null || list. size() == 0) { return false; String firststring = list. get(0); return firststring != null && firststring. length() == 5; //a method that takes an arraylist as argument and returns true if it contains a string of length 5, false otherwise. Arraylist is empty, return false public boolean hasstringoflength5(arraylist list) { if (list == null || list. size() == 0) { return false; for (string s : list) { if (s != null && s. length() ==5) { return true; return false; Use a regular loop public int howmanystringsoflength5_v2(arraylist

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 Questions