arraylist problems?

arraylist problems?

myprogram needs to ask the user for a file name. The file will contain a name on each line. Put each of the names into an ArrayList.

After you have put all of the names into the ArrayList search through the list and print out the following information;

Print out the longest name
Print out the shortest name
print out the total number of characters in all of the names.
print out the average number of characters per name
print out the whole list after the previous four pieces of information.

i have this so far. help with at least one aspect?

import; import; import; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Scanner;

public class project1 {

    public static void main(String[] args) throws IOException

          String filename = "";
          String longestString ="";
          int i;

          ArrayList<String> filestrings = new ArrayList<String>();

          Scanner keyboard = new Scanner(;

          System.out.print("Enter the name of the file you would like to search:");
          filename = keyboard.nextLine();

          File file = new File(filename);

          if (!file.exists())
          System.out.println("The file " +filename+ " is not found.");


          File file1 = new File(filename);
          Scanner inputFile = new Scanner(file);

          while (inputFile.hasNext())

          String line = inputFile.nextLine();
          System.out.println("There are " + filestrings.size() + " words in this document.");

View Answers


Related Tutorials/Questions & Answers:
arraylist of an arraylist
arraylist in java
ArrayList object
ArrayList elements
comparing arraylist of an multi dimensional arraylist
accessor arrayList
ArrayList in java
ArrayList programe
Cannot assign an ArrayList to an empty ArrayList
vector and arraylist
arraylist problems?
java arraylist
Remove multiple elements in arraylist
ArrayList as an argument to another class
How to Convert ArrayList to Array?
Java ArrayList Example
Can ArrayList accept an ImageIcon >>????
Core Java-ArrayList
Diff between ArrayList and Vector?
assigning arraylist to combo box
Two - dimension arraylist
to use ArrayList in the place of Vector
to use ArrayList in the place of Vector
Collection : ArrayList Example
Convert ArrayList to Array
Convert Array to ArrayList
Unexpected Behaviour of ArrayList
Creating Multiple ArrayList
creating own ArrayList without Collections?
dispalying arraylist values in table form
cannot display an arrayList in JSP
Arraylist from row values
query regarding arraylist
ArrayList question plz solve it
maximum size of arraylist - java
Java arraylist duplicate elements search
Collection : ArrayList Example
Question in Create Arraylist ?
Sorting arraylist without using Collection.sort()
Convert List to ArrayList
Arraylist in java