Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In JAVA: Exercise 1.7: Convert the above C linked list code into Java. Make the program print out the data for each node. Consider this

In JAVA: Exercise 1.7: Convert the above C linked list code into Java. Make the program print out the data for each node.

image text in transcribed

Consider this C code for a manually defined Linked List from C Module 4 struct LNode int data LNode* next; struct LList I; int mainO LNode* head; struct LList* list; struct LNode a, *b, * c: list = NULL ; a = NULL; b = NULL; c = NULL; list-malloc(sizeof(struct LList)); amalloc(sizeof(struct LNode)); bmalloc(sizeof(struct LNode)); c malloc(sizeof(struct LNode)); list->heada a->data = 45; a->next-b; b->data = 89; b->next c; c->data = 52; c->nextNULL; How do we convert this C code into Java code? no structs! o Define a class for each data type no malloc o instantiate object with new define constructor to initialize objects don't need to initialize references to nul don't need to differentiate between local structs and struct pointers o in Java, everything is a pointer! o use . instead of -> * Exercise 1.7: Convert the above C linked list code into Java. Make the program print out the data for each node

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

8. Identify the meeting with the goddess in The Elephant Man.

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago

Question

b. Why were these values considered important?

Answered: 1 week ago