Question
class 1 public class Link { public int iData; public double dData; public Link next; public Link(int id, double dd) { iData=id; dData=dd; } public
class 1
public class Link { public int iData; public double dData; public Link next; public Link(int id, double dd) { iData=id; dData=dd; }
public void displayLink() { System.out.print("{" +iData +"," + dData +"}"); } }
class 2
public class LinkListApp { public static void main(String[] args) { LinkList theList = new LinkList(); // create list theList.insertFirst(22,2.99); theList.insertFirst(44, 4.99); theList.insertFirst(66,6.99); theList.displayList(); //////////////////////////// Link f= theList.find(44); if(f != null) System.out.println("Found link with key" + f.iData); else System.out.println("Can't find link"); //////////////////// Link d= theList.delete(66); if(d != null) System.out.println("Deleted link with key" + d.iData); else System.out.println("Can't delete link"); /////////////////////// theList.displayList(); }// end main
}//end class
class 3
public class LinkList {
private Link first; //////////////////////////////////////////// public LinkList() //constructor { first= null; } //////////////////////////////////////////// public boolean isEmpty() { return(first==null); } ///***Write here the insertFirst Method ***//
/////** write here the find Method ***///////// ///***Write here the deletFirst Method ***// //////write here the delete Method any position**///// ///***Write here the display Method ***// }
Java program :)
Update the class Link and add different variables such String name, int ID, float GPA
Take the inputs from user to enter data of linkedlist
insertFirst Method ()
deleteFirst Method ()
find Method () // search key taken from user
delete any position Method() // delete specific key taken from user
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started