Skip to content

Inserting a node into a linked list in constant-time?

I’m working on an assignment that is telling me to assume that I have a singly linked list with a header and tail nodes. It wants me to insert an item y before position p. Can anybody please look over my code and tell me if I’m on the right track? If not, can you provide me with any tips

Output RFC 3339 Timestamp in Java

I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). java.util.SimpleDateFormat does not seem to output timezone offsets in the hour:minute format, it excludes the colon. Is there a simple way to get that timestamp in Java? Also, SimpleDateFormat cannot properly parse the example …

What is meant by immutable?

What exactly does immutable mean – that is, what are the consequences of an object being mutable or immutable? In particular, why are Java’s Strings immutable? My understanding is that the StringBuilder type is something like a mutable equivalent to String. When would I use StringBuilder rather th…

Can java’s assert statement allow you to specify a message?

Seems likes it might be useful to have the assert display a message when an assertion fails. Currently an AssertionError gets thrown, can you specify a custom message for it? Can you show an example mechanism for doing this (other than creating your own exception type and throwing it)? Answer You certainly ca…

Remove HTML tags from a String

Is there a good way to remove HTML from a Java string? A simple regex like will work, but some things like & won’t be converted correctly and non-HTML between the two angle brackets will be removed (i.e. the .*? in the regex will disappear). Answer Use a HTML parser instead of regex. This is dea…

What is the best way to do GUIs in Clojure?

What is the best way to do GUIs in Clojure? Is there an example of some functional Swing or SWT wrapper? Or some integration with JavaFX declarative GUI description which could be easily wrapped to s-expressions using some macrology? Any tutorials? Answer I will humbly suggest Seesaw. Here’s a REPL-base…