Advertisement
Rattin1999

Untitled

Nov 5th, 2020
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. public class LinkedList {
  2. int data;
  3. LinkedList next;
  4.  
  5. public LinkedList(int value){
  6. this.data = value;
  7. }
  8. public void insert(int value){
  9. if(next == null){
  10. next = new LinkedList(value);
  11. }
  12. else {
  13. next.insert(value);
  14. }
  15.  
  16. }
  17.  
  18. public void search(int value){
  19.  
  20. if(value == data){
  21.  
  22. System.out.println(value + " ase");
  23.  
  24. }else {
  25.  
  26. if(next != null){
  27. next.search(value);
  28.  
  29. }else {
  30. System.out.println(value + " nai");
  31. }
  32. }
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement