The Java Scanner example: the Linux test run
Continued coverage of the Java Scanner example, this time run on Linux.
To find the start of this thread, along with the source code of my Java Scanner example, see my post here. I discuss a test run on Windows here.
My Linux tests are run on Ubuntu 14.04; it uses the bash shell. Here’s one of my command line calls:
java TryScanner $56.92 \$56.92 26 here 54.e-3 678a a678 5.4f 5.4d
The result:
Readable number: 6.92 //A little surprising?
Not a readable number: $56.92
Readable number: 26.0
Not a readable number: here
Readable number: 0.054
Not a readable number: 678a
Not a readable number: a678
Not a readable number: 5.4f
Not a readable number: 5.4d
Apparently, in bash, the Java Scanner program does interpret $56.92 as a readable number: 6.92. If we escape the dollar sign like so: \$56.92, then the Java Scanner program sees the input as $56.92, which it deems an unreadable number. Compared to the Windows test run yesterday, there are no other surprises in the results of this one.
I’m no expert on operating systems, but I believe I know why bash handles the dollar sign input differently from Windows. I’ll be sharing my suppositions about that in a coming post.
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.