Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!

tangara goh

Ranch Hand
+ Follow
since Dec 27, 2009
I am a beginner in Java and hope to pick up the trade secrets so that I can move on to Android development
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tangara goh

Stephan van Hulst wrote:What examples are you looking at?

I think you're approaching this the wrong way. Looking at examples of linked lists and making notes and trying to replicate them will only get you so far. Instead, you need to *think* about the problem and try to design your classes yourself.

I want you to start by first designing a classical singly linked list. Start with the public methods: Those methods that should be visible to anybody that wants to use the class.

Do NOT implement the methods yet, and show me ONLY the methods that you think should be visible to a user of the list. Here is something to start you off with:

Hi Stephan,

I am quite clear about Singly Linked list as I understand that you can only traverse forward and not backward, unlike a doubly linked list where you can use the tail and connect back to the head or the position of a node.

The thing is I am trying to replicate that method from HackerRank and I am stumped as to how to make it works which I think it is not possible to do it with the existing methods because there is no way to do a sorting with

Node sortedInsert(Node node, int data);

My latest attempt I am only able to print the data but it is not sorted.

1 week ago

Stephan van Hulst wrote:Why didn't you do what I asked you to?

I'm going through your code.  Can I confirm that there is no need to have private int n at DoublyLinkedList ? because I see all the examples I have seen so far all have that private int n field.
1 week ago

Stephan van Hulst wrote:No. First I want you to write a DoublyLinkedList class and a Node class, without implementing the methods, so I only want see method signatures. That way, I can see whether you have understood the concepts of abstraction and single responsibility.

Try not to look at the classes I've shown you earlier, design them yourself from scratch.

Hi Stephan,

After comparing all my notes, I came up with this below but still I can't make it print and I don't think it is right either.

But, I am not sure how to print it out to see the first result before I look at things again.

1 week ago

Stephan van Hulst wrote:The IDE didn't make you do anything. YOU are the programmer, and YOU decide how the program should be written. The IDE only makes suggestions, which are not always helpful.

Do you know what the static keyword does?

Hi Stephen,

A static method in Java is a method that is part of a class rather than an instance of that class. Every instance of a class has access to the method. Static methods have access to class variables (static variables) without using the class's object (instance). Only static data may be accessed by a static method.

Tks for asking me as I get to revised.

I have since changed the Node to include the DoublyLinkedList as a parameter but I have yet able to churn out the sorted list.

Hope that you could give me a hint how to make that happen. Tks again.
1 week ago

Stephan van Hulst wrote:Why would your code print a six? Your append(Node) method does nothing. Even if it did what it was supposed to do, it would print three sixes instead of one, because the node you're appending links to 2 additional sixes.

Your code is a mess. Here's a list of things you should fix:

Yes, indeed.  I am very depressed, as I was terminated even though I worked hard and was told I do not know how to do an import packages.  All in all, I faced lots of people that are prejudiced against me but I am aware I am still very much inexperienced.  But, they went back against their words of renewing my contract if I could deliver, even though I have already delivered many assignment over the past months.

So, I am trying to look at the code again.  I realised the one that I have posted is using inserting before and after as per  tutorial -

Now, I hope to seek advice how to do a test on the code base on the code below ?

The IDE made me changed the Node head and tail to static but I feel it is not quite right cos how can it be static when a node is insert in front or at the tail, then the node data will change also.

Overall, I am lost how to do a public void main on this code base that has 2 static classes ...
1 week ago
Hi guys,

I am running into a doubly linked list problem.  This is relating to a question by HackerRank -

TBH, I actually got the answer from the discussion group.
Now, I tried to run a test to see how it will pan out in term of result in my local IDE but the 6 will not show up as the next one

the result is

0 The given previous node cannot be NULL
Created DLL is:
Traversal in forward Direction
1 2 4 5

I am totally lost in this but I am also in no mood to do as I was told that no use even if i had delivered on my job because i had asked a question on a sql which i could find on the internet but the 0.5 day deadline given to me forced me to ask..
I am so sad now.
2 weeks ago

Paul Clapham wrote:

Carey Brown wrote:Sure looks like the Git  code has a bug which I'm too tired right now to chase down Git problems.

It shouldn't use "n", it should use one of the variables which are already defined. There's only a very small number of them and if you know how a linked list is supposed to work it shouldn't be hard to fix the error.

Hi Paul,

Thanks for the tips.  Actually till now I am still not very sure on how to use LinkedList, even though I have been practising, most of the time seeing how others write the codes and studied from there.

It is working now.

But, I am puzzled at the Node part

So, I checked back the pdf, there is no

this.fLink = this.bLink = null;

Is this considered correct ? is fLink refer to first item on the link and bLink refers to last item on the link ? Is Node and Link the same thing ?

Thanks again.
3 weeks ago

Carey Brown wrote:Sure looks like the Git  code has a bug which I'm too tired right now to chase down Git problems.

No worries Carey.  Do take a rest and when you feel better than you let me know.

Anyway, I don't think i can make it for this DSA test cos really till now I haven't enough practice to be able to make it.

Furthermore, I got to quickly find another job soon before this one disappeared....
3 weeks ago

Carey Brown wrote:Please post the *COMPLETE* error message (cut&paste, not screenshot).

It just says n cannot be resolved to a variable.
3 weeks ago
Hi guys,

I read this Robert-Lafore book which i have downloaded the free pdf but I was too lazy to type out the code and so I copied this from the github which has the book code.

I hope to find out this github code on Double LinkedList is it correct because there is this part that appear as error in Eclipse IDE

Thanks for your help again.
3 weeks ago
Hi guys,
I have been "battling" with LinkedList concept till now and I am still LOST.
First, I discovered sometimes instead of writing Node, then people use LinkedNode and etc etc.

So, now I am back to reivising the basic before I make an attempt to to that HackerRank insert node at specific node again.

I hope someone can tell me how do I make the following code to make it print

cos now it is printing


the code is

1 month ago
Hi guys,

I refer to this question in Hackerrank :

there is this part that said

so, the solution :

the part on why A < 5 and not A <= 5 stumbled me...why < 5 and not <=5 ? I am confused what a range is

And I google alot but can't find any topic on it.

Hope someone can let me know why not <=5 i mean =5 is inclusive of 5 right ?
1 month ago
Hi guys,

I have been trying to change this pom in maven to make it run in wildfly in Eclipse without avail.

The pom is basically getting from this site :

and here I am trying to create a new xhmtl which I get from the showcase which illustrate how the dataModel works :

Here's I the pom that I have now, removing the jetty portion and adding jboss-web.xml

The new pom :

Deleted nbactions.xml :

and the output is always
1 month ago

Tim Holloway wrote:

Himai Minh wrote:It seems like your Maven compiler is looking for JDK 8 instead of 11.

No. As Stephan said, it's telling the Java compiler that Maven is running under to generate code for Java 8. The compatibility level is a command-line argument to the javac command. It's not going to look anywhere for any other version of Java, just tell Maven's Java what version to pretend to be.

I managed to fix it.  I guess it must be my exhaustion that causes all these what seems like a straightforward job yet I spent so much time on it.

Sorry guys to have you look into it...I know it can be taxing on you guys also...

Stephan van Hulst wrote:

Campbell Ritchie wrote:What is a property descriptor?

An object that describes a bean property. In other words, you can use it to perform reflective operations on a property "x", regardless of whether that property is represented by a field x or a getter getX().

Yes.  the primeface community uses that to get the property values and make it render it the browser i think.

Of course it is not done by me...i wish i can but really my Java skill still sucks, still can't pass that test which I have postponed.....and now my job continuation is no where in sight

Erm...can i know what is the reason to change it from static final to private ?
1 month ago