Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LinkedList {
- int data;
- LinkedList next;
- public LinkedList(int value){
- this.data = value;
- }
- public void insert(int value){
- if(next == null){
- next = new LinkedList(value);
- }
- else {
- next.insert(value);
- }
- }
- public void search(int value){
- if(value == data){
- System.out.println(value + " ase");
- }else {
- if(next != null){
- next.search(value);
- }else {
- System.out.println(value + " nai");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement