import java.io.*;
import java.util.*;
class Slip30
{
public static void main(String ar[]) throws IOException
{
int n;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter size of linkedList...");
n = Integer.parseInt(br.readLine());
LinkedList <String> ll = new LinkedList <String>();
for(int i=0;i<n;i++)
{
System.out.println("Enter the element...");
String str = br.readLine();
if(ll.contains(str)==true)
{
System.out.println("The element is already existing...");
i--;
}
else
ll.add(str);
}
Iterator <String> it = ll.iterator();
System.out.println("Contents of Linked List using iterator...");
while(it.hasNext())
System.out.println("\t" + it.next());
System.out.println("Enter the element to search : ");
String search = br.readLine();
int pos = ll.indexOf(search);
if(pos== -1)
System.out.println(" The element not found" );
else
System.out.println(" The element found at location : " +pos);
}
}
Write a program that reads a file and counts the number of occurrences of each letter
ReplyDeleteNice Blog, Thanks for sharing such a informative blog with us. keep sharing!!
ReplyDeleteAre you looking for free online java tutorial?
free java tutorial!
hello java programing