By Ryan on October 12, 2009
A question was raised today in my computer science class. The question went something along the lines of:
If you print out two ints joined by a plus sign, are they added or are they printed out separately?
My initial response that if you did something like println(10 + 11); it would print out 1011. I was [...]
Posted in Java | Tagged concatenation, Java, join, string
By Ryan on June 24, 2009
A typical java file starts with it’s class name and for beginner programmers, you’ll usually have a public static void main(String[] args) line a couple lines below that class name too.
Many beginner programmers aren’t taught what exactly the String[] args part means though. They’ll learn arrays eventually but they still won’t understand the point of [...]
Posted in Java | Tagged args, command line arguments, Java, main, string, Tips
By Ryan on February 26, 2009
No, not a Hash Table. A hash as in sha1 or md5. After a few days of searching and tinkering sometime in December 2007, I wrote this static driven Java Hash file for sha1. So if you want sha1 hashes in your program (for strings and files), this might help you out. At this point, [...]
Posted in Java | Tagged file, hash, hex, Java, plaintext, sha1, string
By Ryan on December 19, 2008
In Java, there is a particular case where using Scanner can cause a request for input to be totally ignored. I’ve called it the int-skip-string case. Basically, you enter an int using Scanner.nextInt() and proceed to enter a string but just as you’re about to type it, you notice that your chance is gone! And [...]
Posted in Error, Java | Tagged int, Java, newline, nextInt, nextLine, scanner, skip, stop, string
By Ryan on October 30, 2008
We needed a method today in class that would capitalize a particular character in a string. You decide on the character based on it’s index (from 0 right now, but I don’t know if I’ll keep it that way.)
The method is extremely simple but avoids sub-strings and annoying logic that sub-stringing brings.
Sadly in Java you [...]
Posted in Java | Tagged enhancement, Java, method, string