The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled Java Code
Posted by: Manu Gupta | February 4, 2010 @ 2:46pm
Java Code
[
Download
]
import java.util.*; import java.io.*; class DuplicateEntryException extends Exception { String detail; DuplicateEntryException(String a) { detail = a; } public String toString() { return "User Defined Exception : "+detail; } } class a1 { static LinkedList l1; private static emp_struct input() throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); emp_struct obj = new emp_struct(); obj.emp_id = br.readLine(); obj.name = br.readLine(); obj.salary = Double.parseDouble(br.readLine()); obj.dept = br.readLine(); try{ System.out.println("In try block"); // l1.addFirst(obj); search(obj); l1.addFirst(obj); }catch(DuplicateEntryException e){ System.out.println(e); obj = input(); } return obj; } static boolean search(emp_struct obj) throws DuplicateEntryException { System.out.println(l1); int begIndex = 0; for(begIndex =0;begIndex<l1.size();begIndex++) { emp_struct chkCase = (emp_struct)l1.get(begIndex); String chk = chkCase.getEmpID(); System.out.println(chk +"&" +obj.emp_id); if(chk.equals(obj.emp_id)); throw new DuplicateEntryException("Duplicate entry found"); } return true; } public static void main(String args[]) throws IOException { l1 = new LinkedList(); emp_struct obj; int i=0; for(i=0;i<10;i++) { obj = input(); } } } class emp_struct { public String emp_id; public String name; public double salary; public String dept; public String getEmpID() { return emp_id; } public String toString() { return emp_id+"\t"+name+"\t"+salary+"\t"+dept; } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.60 / 8
65 Votes
http://codebin.yi.org/482
page generated in 0.00 seconds