Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 71148

Java (not to be confused with JavaScript) is a class-based, object-oriented, strongly typed, reflective language and run-time environment (JRE). Java programs are compiled to bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.

5 votes
Accepted

RemoveDuplicateElement

Style Comments I stated this in a comment (pun unintended but a happy side effect) that I think comments like this are unneeded and make the code harder to read. if (null == inputArray || 0 == inpu …
Captain Man's user avatar
0 votes
0 answers
55 views

Attributing code licensed under Creative Commons from Stack Overflow in Javadoc

The title is pretty clear. I have a code snippet I took from Stack Overflow that's licensed under Creative Commons and I want to attribute it properly. My understanding is with Creative Commons you ne …
Captain Man's user avatar
3 votes

A generic cache object

The Java Class Library prefers NullPointerException to IllegalArgumentException when the element is required to be non-null. I think it's better to match their style here rather than be opinionated. …
Captain Man's user avatar
1 vote

Standard fizz (3) buzz (5)

I suggest always using braces on any if statement. It's too easy to accidentally screw up something if you don't. It doesn't add many extra lines, especially with long chains like this since it only a …
Captain Man's user avatar
0 votes

And the little one said "Roll over"

The only thing I can think to add to others' is that the comments in the main method are superfluous. // Declare a reference variable of type song99bottles - new object song99bottles go = new song9 …
Captain Man's user avatar
3 votes
2 answers
12k views

Checking if an element sastifying a condition in a list comes before another of a different ...

This is for Java 6 and uses Guava. It's a little ugly and I'm worried I missed some obvious way to do it a lot better. …
Captain Man's user avatar
9 votes

Basic Java library to hold books

return Optional.empty(); } My reasoning against returning null is this: It is never 100% clear if a method will return null or not in Java and maybe someone will think this won't so they won't guard …
Captain Man's user avatar
1 vote

Replace space with %20

Everyone has commented about how to better replace the spaces, I will answer how to better test. I suggest making a proper unit test with Junit. This way you do not need to manually look at your outp …
Captain Man's user avatar
1 vote

Reimplementation of a Hashtable and hash function

In Java, the hashCode() method takes this and returns an int, in my little metaphor above [Decoder] depends on the type. …
Captain Man's user avatar
3 votes
Accepted

Generating a topographic string

The reason I made getLevelContent a separate method is to avoid multiple for loops for each level of the output (3, 2, and 1). Is separating into methods, as I have done here, a good way to solv …
Captain Man's user avatar
1 vote

Largest palindrome in a string

So long as you use && instead of & java will use short circuit evaluation and not do isPalindrome(data). But! …
Captain Man's user avatar
3 votes
Accepted

Java 8 unit test for third-party data feeds

I am only going to talk about the sports method, from there you should be able to get the info you need for the others as they are all basically the same. DRY isn't a big priority As I said in my ea …
Captain Man's user avatar
6 votes

Binary Calculator in Java

Pimgd provided a good point about your Operations class, but if you wanted to keep it I would suggest making these changes to it as it's a "utility class" Make it a final class Add a private constru …
Captain Man's user avatar
2 votes

Random letter test

randomUpperCaseLetter() I will assume that RandomLetter.generate() actually does return something randomly* generated. (Maybe it should be named generateUpperCase() instead?) Unit tests should be de …
Captain Man's user avatar