java - Find out if an ArrayList has a certain char or partial string in it and then print the results -
The code is not displayed if it has only one letter, like flowers 'name'>
private Static zero filter flower (arrelisted & lt; flower & gt; flower) {string flone name = getString ("Enter the partial name of the flower:"); Boolean flr = flower cambodia (flomen); If (flare == true) {system.out.println ("\ n flower" + filename + "\ n" are filtered by); Println (floName); } Else {System.out.println ("There is not a flower with the following:" + flonym + "" + "\ n"); }}
Assume that your flower class has a name Member and a Greater for it: Private Static Zero Filter Flower (Arreelist & lt; Flowers & gt; Flowers) {String Partial Name = Friendly String ("Enter Partial Name of the Flower "); ArrayList & LT; Flowers & gt; Filtered flowers = new arreelist & lt; Flowers & gt; (); (Flower flowers: flower) for (if (flower.getName (). In (partial name)) {filteredFlowers.add (flower);}} if (filtered flower size.)> gt; {System.out.println ( "Which contains flowers with" + partial name ":"); for (flower flowers: filtered flowers) {System.out.println (flower.getName ());}} and {System.out.println ("Anyone Flower is not "+ partial name);}}
Comments
Post a Comment