Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java. I need a method (show below which is called unique) that returns the highest 10 even numbers in the list that are different. 2nd

Java. I need a method (show below which is called unique) that returns the highest 10 even numbers in the list that are different. 2nd image is example file (file has about 500 numbers) numbers.csv Using the method the the output ill have is Top ten unique even numbers : #, #, #, #, #, #, #, #, #, #. Thanks.

image text in transcribed

image text in transcribed

3 9 1+ import java.util. 5 6 class Num 7 { 80 public static List readFile(ServletContext context, String filename) { List contents new ArrayList(); 10 try { 11 InputStream is = context.getResourceAsStream(filename); 12 if (is != null) { 13 InputStreamReader isr = new InputStreamReader(is); 14 BufferedReader reader = new BufferedReader(isr); 15 String text; 16 while ((text = reader.readLine()) != null) { 17 contents.add(text); 18 } 19 } 20 } catch (Exception e) { 21 e.printStackTrace(); 22 } 23 return contents; 24 } 25 public static List unique(List content) 27 { 28 29 30 return null; 31 } 32 } 260 A B 1 2 3 4. 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 70116 48116 8014 99501 45011 44805 60632 95111 57105 21224 19443 11953 90034 44023 78045 85013 37110 53207 48180 61109 19014 95111 75062 12204 8846 54481 66218 21601 10011 77301 43215 88011 7660 8812 10025 70002 10011 93012 78204 67410 97754 66204 99708 33196 99712 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 3 9 1+ import java.util. 5 6 class Num 7 { 80 public static List readFile(ServletContext context, String filename) { List contents new ArrayList(); 10 try { 11 InputStream is = context.getResourceAsStream(filename); 12 if (is != null) { 13 InputStreamReader isr = new InputStreamReader(is); 14 BufferedReader reader = new BufferedReader(isr); 15 String text; 16 while ((text = reader.readLine()) != null) { 17 contents.add(text); 18 } 19 } 20 } catch (Exception e) { 21 e.printStackTrace(); 22 } 23 return contents; 24 } 25 public static List unique(List content) 27 { 28 29 30 return null; 31 } 32 } 260 A B 1 2 3 4. 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 70116 48116 8014 99501 45011 44805 60632 95111 57105 21224 19443 11953 90034 44023 78045 85013 37110 53207 48180 61109 19014 95111 75062 12204 8846 54481 66218 21601 10011 77301 43215 88011 7660 8812 10025 70002 10011 93012 78204 67410 97754 66204 99708 33196 99712 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions