No LL in Java

I tried writing some linked list programs in Java. In my mind.

OK. First step, get the questions ready. I got them ready (find the middle node. Find if there is a loop. find nth node from end of list etc. etc. etc). And I remembered how I had solved them. In C language.

Now for the second step. Start java code. May be in Eclipse IDE. But eclipse IDE kept crashing mentioning errors I could not fathom. Do you ever "fathom" these error messages? No (unless it is Nullpointer exception aka segmentation fault)!!. You just google them - or stack-overflow them. I didn't do that either.

Third step. Write actual code without IDE. Many of you many not know - but you can still write java code in vi editor. And then compile it with java -ka (javac). I had done it with all my test programs so far - which means I can do it with linked list program as well.

But you already see the problem. Don't you? vi does not give you suggestion about methods and syntax errors. Unless you already know what are the fields and methods of your target class, you can't possibly write the code. So, no vi editor?

Next step is realization. The API for linked list has all the methods necessary. My code need to just call these. Should it? For example take the question - find the middle node of a linked list using single iteration. Call size() method and divide by 2?

That can not be right. Life is never never so simple. So what if I do not use LinkedList collection class - instead write my own class. Just like what I had done in C? But how do I write linkedlist without using pointers?

So all the questions based on linkedlist are completely bogus in Java. That's what I like to believe.

So let me instead keep ctrl c and ctrl v ing simple theory questions and objective questions.

PS: I was wrong again. My son told me how to write a linkedlist in Java without using library functions. You can find these programs soon enough in my other blog. 

Comments

Popular posts from this blog

ಹೂಗಳು

ಎಮ್ಮೆ

Not for nation