fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5.  
  6. class ListItem {
  7. public ListItem next;
  8. private int emp_id;
  9.  
  10. ListItem(emp_id) {
  11. this.next = NULL;
  12. this.emp_id = emp_id;
  13. }
  14. }
  15.  
  16. class LinkedList {
  17. public ListItem head;
  18.  
  19. private int count;
  20.  
  21. this.head = NULL;
  22. this.count = 0;
  23. }
  24.  
  25. public void add(int emp_id) {
  26. ListItem prev = this.head;
  27. while(prev != NULL) {
  28. prev = prev.next;
  29. }
  30. ListItem item = new ListItem(emp_id);
  31. if(this.count === 0)
  32. this.head = item;
  33. else
  34. prev.next = item;
  35.  
  36. this.count++;
  37. }
  38. }
  39.  
  40. class undefined {
  41. public static void main() {
  42. LinkedList list = new LinkedList();
  43. list.add(5);
  44. list.add(6);
  45. ListItem item = list.head;
  46. while(item != NULL) {
  47. System.out.println(item);
  48. item = item.next;
  49. }
  50. }
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:10: error: <identifier> expected
	ListItem(emp_id) {
	               ^
Main.java:32: error: illegal start of expression
		if(this.count === 0)
		                ^
2 errors
stdout
Standard output is empty