Groups | Search | Server Info | Login | Register
Groups > comp.lang.java.programmer > #5403
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: The greeting code in Java |
| Date | 2011-06-19 16:05 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <itlkrg$tb2$1@dont-email.me> (permalink) |
| References | <f61fee62-589e-4ad1-a9ef-a54e2b589e5b@s9g2000yqm.googlegroups.com> <ld8sv6tugbkdq7n1dc0d4ja0o604rr6n5q@4ax.com> <b70ab7d1-fe03-413e-ba87-6819ae24973e@hd10g2000vbb.googlegroups.com> |
On 6/19/2011 3:15 PM, Saeed Amrollahi wrote:
> [...]
> What is the Scanner? Why we use nextLine? What's the relation of
> such concepts with a simple greeting program.
The Scanner class and its nextLine method are part of an I/O
library that offers more power and flexibility than your program is
capable of using.
Unfortunately for you, the designers of Java chose not to
provide a built-in I/O facility dumbed down to the level you need.
You're not using a tenth of the power of Scanner, but that would
be a poor reason for Scanner to jettison its other nine-tenths.
> Why the code for writing "Hello, world" is in chapter 1, page 1
> of The Java Programming Language, but the code of greeting may be in
> Chapter 20!
Permute the chapter numbers if it makes you happier. For example,
you don't need to know how to write constructors, you don't need to
understand the `long' type, you don't need to know about nested classes,
and so on, and so on. Move chapter 20 ahead of all those, if you like.
More seriously, the purpose of a "Hello, world" program is not
to teach you the language (whatever language) nor to illustrate its
capabilities. It is a throat-clearing exercise intended to test
whether the compiler/interpreter/libraries/runtime/licenses/whatnot
are set up correctly. "Testing, testing, one, two, three" is not
intended to convey a message, but to check that everything from the
microphone to the speaker is properly connected and powered on. Do
not judge the PA system by the banality of its first message.
I imagine you are a C++ practitioner trying to learn Java, but
making the mistake of trying to understand Java in C++'s terms. Have
you ever hear the phrase "A real programmer can write FORTRAN in any
language?" Try not to commit that error, but instead look at Java on
its own merits (and its own demerits; Java's not perfect).
Bruce Eckel's "Thinking in Java" gets a lukewarm reception (at
best) from the experts, and I don't know whether it's been kept up
to date as Java has developed and changed. However, it has one virtue
I found helpful Back In The Day, and you may find helpful now: True to
its title, it really does try to explain Java in Java's own terms, and
not by saying "It's just like Lisp except ..." A goodly dose of that
mindset might stand you in good stead.
--
Eric Sosman
esosman@ieee-dot-org.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 06:05 -0700
Re: The greeting code in Java rossum <rossum48@coldmail.com> - 2011-06-19 17:36 +0100
Re: The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 12:15 -0700
Re: The greeting code in Java Martin Gregorie <martin@address-in-sig.invalid> - 2011-06-19 19:46 +0000
Re: The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 22:34 -0700
Re: The greeting code in Java Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2011-06-23 11:43 +0300
Re: The greeting code in Java Martin Gregorie <martin@address-in-sig.invalid> - 2011-06-20 10:13 +0000
Re: The greeting code in Java Michael Wojcik <mwojcik@newsguy.com> - 2011-06-22 09:29 -0400
Re: The greeting code in Java Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-19 16:00 -0400
Re: The greeting code in Java Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-19 16:05 -0400
Re: The greeting code in Java Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-19 22:40 -0700
Re: The greeting code in Java rossum <rossum48@coldmail.com> - 2011-06-19 22:28 +0100
Re: The greeting code in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-06-19 21:14 -0700
Re: The greeting code in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-06-19 21:23 -0700
Re: The greeting code in Java blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-20 19:20 +0000
Re: The greeting code in Java Ney André de Mello Zunino <zunino@softplan.com.br> - 2011-06-22 15:55 -0300
csiph-web