Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2177 > unrolled thread
| Started by | bobwhite@mixnym.net |
|---|---|
| First post | 2012-10-25 14:50 +0000 |
| Last post | 2012-11-01 13:47 -0400 |
| Articles | 20 on this page of 29 — 9 participants |
Back to article view | Back to comp.lang.java.help
Please recommend a book bobwhite@mixnym.net - 2012-10-25 14:50 +0000
Re: Please recommend a book Nigel Wade <nmw@ion.le.ac.uk> - 2012-10-25 17:44 +0100
Re: Please recommend a book markspace <-@.> - 2012-10-25 09:50 -0700
Re: Please recommend a book bobwhite@mixnym.net - 2012-10-26 14:54 +0000
Re: Please recommend a book "Charles Hottel" <chottel@earthlink.net> - 2012-10-26 11:14 -0400
Re: Please recommend a book Roedy Green <see_website@mindprod.com.invalid> - 2012-10-26 09:32 -0700
Re: Please recommend a book David Lamb <dalamb@cs.queensu.ca> - 2012-10-26 17:17 -0400
Re: Please recommend a book Lew <lewbloch@gmail.com> - 2012-10-26 15:04 -0700
Re: Please recommend a book bobwhite@mixnym.net - 2012-10-28 22:05 +0000
Re: Please recommend a book bobwhite@mixnym.net - 2012-10-29 11:07 +0000
Re: Please recommend a book David Lamb <dalamb@cs.queensu.ca> - 2012-10-29 10:30 -0400
Re: Please recommend a book bobwhite@mixnym.net - 2012-10-29 19:09 +0000
Re: Please recommend a book Patricia Shanahan <pats@acm.org> - 2012-10-29 12:38 -0700
Re: Please recommend a book Lew <lewbloch@gmail.com> - 2012-10-29 13:42 -0700
Re: Please recommend a book markspace <-@.> - 2012-10-29 15:29 -0700
Re: Please recommend a book Roedy Green <see_website@mindprod.com.invalid> - 2012-10-31 07:28 -0700
Re: Please recommend a book bobwhite@mixnym.net - 2012-11-03 20:37 +0000
Re: Please recommend a book Lew <lewbloch@gmail.com> - 2012-11-03 16:22 -0700
Re: Please recommend a book markspace <-@.> - 2012-11-03 20:42 -0700
Re: Please recommend a book bobwhite@mixnym.net - 2012-11-04 14:40 +0000
Re: Please recommend a book Lew <lewbloch@gmail.com> - 2012-11-04 20:27 -0800
Re: Please recommend a book Roedy Green <see_website@mindprod.com.invalid> - 2012-10-26 09:24 -0700
Re: Please recommend a book Roedy Green <see_website@mindprod.com.invalid> - 2012-10-26 09:31 -0700
Re: Please recommend a book Patricia Shanahan <pats@acm.org> - 2012-10-27 06:19 -0700
Re: Please recommend a book bobwhite@mixnym.net - 2012-10-28 21:05 +0000
Re: Please recommend a book bobwhite@mixnym.net - 2012-10-29 12:08 +0000
Re: Please recommend a book Jeff Higgins <jeff@invalid.invalid> - 2012-10-28 19:09 -0400
Re: Please recommend a book bobwhite@mixnym.net - 2012-11-01 14:25 +0000
Re: Please recommend a book Jeff Higgins <jeff@invalid.invalid> - 2012-11-01 13:47 -0400
Page 1 of 2 [1] 2 Next page →
| From | bobwhite@mixnym.net |
|---|---|
| Date | 2012-10-25 14:50 +0000 |
| Subject | Please recommend a book |
| Message-ID | <uwoauarzuw.tovtmy@mixnym.net> |
Hi, Can somebody please recommend a good book for someone who wants to learn Java? I have a lot of programming experience but not with C or Java-based languages. I do understand OO concepts. I've seen many Java books for people with no programming experience and they go too slow for me and leave out important details. I went through about 250 pages of Ivor Horton's Beginning Java but I have no idea when I'll ever be able to do anything beside calculate square roots in Java! Don't get me wrong I think it's a great book but I don't think I'm the target audience. I'm too old for this and don't have time for 1500 page books at least I don't think it should take a thousand pages to be productive in a new language but maybe I am wrong since I don't work in any modern languages. I have no experience in GUI and this is what I hope to use Java for if I can learn it. That chapter is a thousand pages away from where I am now. The other area of difficulty I have is understanding the Java class library documentation. Even when I see an explanation or example in a book about using a class, when I go to the Java doc I don't understand it enough that I could write the sample code from the class doc alone, and I should be able to. I'm missing something here and haven't seen a book that explains how to use this. Obviously it's essential and if I could understand it I think I would get much further with a much thinner book. Thanks, Bob White
[toc] | [next] | [standalone]
| From | Nigel Wade <nmw@ion.le.ac.uk> |
|---|---|
| Date | 2012-10-25 17:44 +0100 |
| Message-ID | <aet8ikFpoe6U1@mid.individual.net> |
| In reply to | #2177 |
On 25/10/12 15:50, bobwhite@mixnym.net wrote: > Hi, > > Can somebody please recommend a good book for someone who wants to learn > Java? I have a lot of programming experience but not with C or Java-based > languages. I do understand OO concepts. I've seen many Java books for people > with no programming experience and they go too slow for me and leave out > important details. I went through about 250 pages of Ivor Horton's Beginning > Java but I have no idea when I'll ever be able to do anything beside > calculate square roots in Java! Rather than ploughing your way through that mighty tome, I would suggest that you try to get a flavour of the language from the Java Tutorials on Oracle's website. There's a very good introduction to Java here: http://docs.oracle.com/javase/tutorial/ This covers a lot of the basics, including an introduction to GUI design with Swing. It's also a pretty good reference work in its own right on Swing. When you've mastered the basics, and are happy with what you've learned and wish to continue, that's the time to bring out the big books. Some people would recommend that your reading should include the Java Language Specification. -- Nigel Wade
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-10-25 09:50 -0700 |
| Message-ID | <k6bqkn$dn0$1@dont-email.me> |
| In reply to | #2177 |
On 10/25/2012 7:50 AM, bobwhite@mixnym.net wrote: > > Can somebody please recommend a good book for someone who wants to > learn Java? Lots. Especially for GUIs, Learning Java by O'Reilly is invaluable. The book is kind of remedial but it has many, many thoughtful examples which are worth far more than the $50 they charge for the book. It also has one of the better explanations of Java generics that I have seen. <http://shop.oreilly.com/product/9780596008734.do> Also don't overlook the Java tutorial. While not really a tutorial, once you get the hang of Java, it also has many examples and good advice too. That goes double for the GUI section. <http://docs.oracle.com/javase/tutorial/> > The other area of difficulty I have is understanding the Java class > library documentation. Even when I see an explanation or example in a > book about using a class, when I go to the Java doc I don't > understand it enough that I could write the sample code from the > class doc alone, and I should be able to. I'm missing something here > and haven't seen a book that explains how to use this. Yes, I had this problem too when I first started with Java. What you are missing, I think, is "time." Java has a much, much larger API than say C. I think many experienced programmers expect Java to be like their other three or for languages, and aren't prepared amount of material they have to absorb. Just stick with it. If you are really in a jam, www.javapassion.com has high-quality courses that do a good job guiding you through learning process. Their course helped me get out of the "muddle" I was in with Java's huge API and focus on just the stuff I needed to know to really learn the language and the base API. After that reading the Java docs was no problem.
[toc] | [prev] | [next] | [standalone]
| From | bobwhite@mixnym.net |
|---|---|
| Date | 2012-10-26 14:54 +0000 |
| Message-ID | <smvivhzpmb.lkxhng@mixnym.net> |
| In reply to | #2179 |
Nigel, Markspace thanks for your helpful comments! My comments within. Nigel said: > Rather than ploughing your way through that mighty tome, I would suggest > that you try to get a flavour of the language from the Java Tutorials on > Oracle's website. > > There's a very good introduction to Java here: > http://docs.oracle.com/javase/tutorial/ > This covers a lot of the basics, including an introduction to GUI design > with Swing. It's also a pretty good reference work in its own right on > Swing. I saw the tutorial on Sun a few years ago and started going through it but I got the same feeling, that I was learning many odd bits and pieces but not putting it all together somehow. And just as I got to the interesting bits I was unable to understand them based on what was in prior sections. I'll go and have another look since people do seem to recommend these. > When you've mastered the basics, and are happy with what you've learned > and wish to continue, that's the time to bring out the big books. Could you recommend one or two good books with broad overall coverage that are bit more concise and focused (self-contained) at the chapter level? Markspace said: > Lots. Especially for GUIs, Learning Java by O'Reilly is invaluable. The > book is kind of remedial but it has many, many thoughtful examples which > are worth far more than the $50 they charge for the book. It also has one > of the better explanations of Java generics that I have seen. When you say remedial does it mean I must know Java already? Or did you mean they're too simplistic? > Also don't overlook the Java tutorial. While not really a tutorial, once > you get the hang of Java, it also has many examples and good advice too. > That goes double for the GUI section. Ah that's what I didn't like about it before. It seems for the first few exercises no programming background is required then suddenly as you get to the worthwhile parts it assumes you already know Java but don't know /this specific thing/ in Java. I was lost. >> The other area of difficulty I have is understanding the Java class >> library documentation. Even when I see an explanation or example in a >> book about using a class, when I go to the Java doc I don't >> understand it enough that I could write the sample code from the >> class doc alone, and I should be able to. I'm missing something here >> and haven't seen a book that explains how to use this. > > > Yes, I had this problem too when I first started with Java. What you > are missing, I think, is "time." Java has a much, much larger API than > say C. I think many experienced programmers expect Java to be like > their other three or for languages, and aren't prepared amount of > material they have to absorb. Just stick with it. I am used to very large APIs I don't that's it. I think one of the problems is the layering of things in Java and OO that I'm not used to. The APIs I'm using are self contained and don't build on other interfaces. I'm lost with all the imports and what you need to get this or that class that depends on zillions of other classes, or why they're needed. In my work all I need to do is pull in the right API and it doesn't need anything else. This is a big change in thinking. And I don't think I understand how to read the API doc. I wish there were a guide to this specific issue. > If you are really in a jam, www.javapassion.com has high-quality courses > that do a good job guiding you through learning process. Their course > helped me get out of the "muddle" I was in with Java's huge API and > focus on just the stuff I needed to know to really learn the language > and the base API. After that reading the Java docs was no problem. If work was paying for this I'd love a site like that but it's for my own interests, not knowing GUI and I'd like to be able to put a GUI on my code and Java seems like a good one to learn. Thanks gents! Bob
[toc] | [prev] | [next] | [standalone]
| From | "Charles Hottel" <chottel@earthlink.net> |
|---|---|
| Date | 2012-10-26 11:14 -0400 |
| Message-ID | <KNGdnTYCvop9NRfNnZ2dnUVZ_rKdnZ2d@earthlink.com> |
| In reply to | #2180 |
<bobwhite@mixnym.net> wrote in message news:smvivhzpmb.lkxhng@mixnym.net... > Nigel, Markspace thanks for your helpful comments! My comments within. > > Nigel said: > <snip> I reccomend books from Mike Murach, see: http://www.murach.com/books/java.htm
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-10-26 09:32 -0700 |
| Message-ID | <7nel88tb2t3hpmnrke0dke1j46s8tsmoqa@4ax.com> |
| In reply to | #2180 |
On Fri, 26 Oct 2012 14:54:53 -0000, bobwhite@mixnym.net wrote, quoted or indirectly quoted someone who said : >I'm lost with >all the imports get an IDE that computes and maintains them for you automatically. See http://mindprod.com/jgloss/ide.html -- Roedy Green Canadian Mind Products http://mindprod.com There are four possible ways to poke a card into a slot. Nearly always, only one way works. To me that betrays a Fascist mentality, demanding customers conform to some arbitrary rule, and hassling them to discover the magic orientation. The polite way to do it is to design the reader slot so that all four ways work, or so that all the customer has to do is put the card in the vicinity of the reader.
[toc] | [prev] | [next] | [standalone]
| From | David Lamb <dalamb@cs.queensu.ca> |
|---|---|
| Date | 2012-10-26 17:17 -0400 |
| Message-ID | <k6eum3$15t$2@dont-email.me> |
| In reply to | #2184 |
On 26/10/2012 12:32 PM, Roedy Green wrote: > On Fri, 26 Oct 2012 14:54:53 -0000, bobwhite@mixnym.net wrote, quoted > or indirectly quoted someone who said : > >> I'm lost with >> all the imports > > get an IDE that computes and maintains them for you automatically. See > http://mindprod.com/jgloss/ide.html > It seemed to me his problem was understanding something that depends on a gazillion imports, not managing the imports themselves.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-10-26 15:04 -0700 |
| Message-ID | <0fdfb5b1-04e9-4ed1-8af0-e80c279ee060@googlegroups.com> |
| In reply to | #2185 |
David Lamb wrote: > It seemed to me his problem was understanding something that depends on > a gazillion imports, not managing the imports themselves. I'm having difficulty how the number of imports impacts the clarity of the code. Imports aren't part of the logic; they simply allow abbreviated names for types and type members. Now if code is hyper-complex and depends on too many other types, that is a structural or architectural problem with the code itself, and not with Java /per se/. But is a "zillion" really above that threshold? How much is the OP's "zillion"? Anyway, the dependency question is easy. If a method needs a capability provided by another module (i.e., class or interface), it depends on that. That's true of every single modular computer language there is, and not unique to Java. Example: If you write a Swing program that uses a 'JPanel' (a type of window widget), then that program depends on 'JPanel'. The imports provide a very simple and compact description of the dependencies, if imports are used. They are optional, after all. But otherwise the FQNs (fully-qualified names) of the constructs provide the same information. The OP seems to be complaining about hard programs, not a hard programming language. Java is really dog-dirty simple as a language. The question of dependencies is one the OP had better master as a programmer generally, because like other fundamental programming skills it's necessary for Java programming, too. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | bobwhite@mixnym.net |
|---|---|
| Date | 2012-10-28 22:05 +0000 |
| Message-ID | <tdcgourdei.kneeso@mixnym.net> |
| In reply to | #2185 |
> On 26/10/2012 12:32 PM, Roedy Green wrote: > > On Fri, 26 Oct 2012 14:54:53 -0000, bobwhite@mixnym.net wrote, quoted > > or indirectly quoted someone who said : > > > >> I'm lost with > >> all the imports > > > > get an IDE that computes and maintains them for you automatically. See > > http://mindprod.com/jgloss/ide.html > > > > It seemed to me his problem was understanding something that depends on > a gazillion imports, not managing the imports themselves. Correct, thanks for reminding them! And more to the point, how to get a handle on this since Java is my first foray into a serious OO language. Bob
[toc] | [prev] | [next] | [standalone]
| From | bobwhite@mixnym.net |
|---|---|
| Date | 2012-10-29 11:07 +0000 |
| Message-ID | <btzvmjycmu.lgaixk@mixnym.net> |
| In reply to | #2185 |
> On 26/10/2012 12:32 PM, Roedy Green wrote: > > On Fri, 26 Oct 2012 14:54:53 -0000, bobwhite@mixnym.net wrote, quoted > > or indirectly quoted someone who said : > > > >> I'm lost with > >> all the imports > > > > get an IDE that computes and maintains them for you automatically. See > > http://mindprod.com/jgloss/ide.html > > > > It seemed to me his problem was understanding something that depends on > a gazillion imports, not managing the imports themselves. Correct, thanks for reminding them! And more to the point, how to get a handle on this since Java is my first foray into a serious OO language. Bob
[toc] | [prev] | [next] | [standalone]
| From | David Lamb <dalamb@cs.queensu.ca> |
|---|---|
| Date | 2012-10-29 10:30 -0400 |
| Message-ID | <k6m3ti$n58$1@dont-email.me> |
| In reply to | #2191 |
On 29/10/2012 7:07 AM, bobwhite@mixnym.net wrote: >> On 26/10/2012 12:32 PM, Roedy Green wrote: >>> On Fri, 26 Oct 2012 14:54:53 -0000, bobwhite@mixnym.net wrote, quoted >>> or indirectly quoted someone who said : >>> >>>> I'm lost with >>>> all the imports >>> >>> get an IDE that computes and maintains them for you automatically. See >>> http://mindprod.com/jgloss/ide.html >>> >> >> It seemed to me his problem was understanding something that depends on >> a gazillion imports, not managing the imports themselves. > > Correct, thanks for reminding them! And more to the point, how to get a > handle on this since Java is my first foray into a serious OO language. OK; it seems to me that if this thread is to help you we (or at least I) need to understand how the large APIs you're used to manage to avoid "zillions of imports" On 26/10/2012 10:54 AM, bobwhite@mixnym.net wrote: > I am used to very large APIs I don't that's it. I think one of > the problems is the layering of things in Java and OO that I'm > not used to. The APIs I'm using are self contained and don't > build on other interfaces. I'm lost with all the imports and > what you need to get this or that class that depends on > zillions of other classes, or why they're needed. In my work > all I need to do is pull in the right API and it doesn't need > anything else. This is a big change in thinking. This seems like the right comment to focus on for me to understand your problem. What kind of "large self-contained API" are you talking about? Can you give an example? For example, is it "large" in that it contains very many methods or procedures, but those procedures take only parameters of simple types like arrays and scalars? If so your problem isn't so much O-O specifically as the more basic idea of abstract data types. If that's the case then maybe we can recommend some targeted readings on that specific subject rather than 1500 pages on every detail of Java. But this is just a guess; we need to know more about your background. > And I don't think I understand how to read the API doc. I wish > there were a guide to this specific issue. Hmm. Well, I rarely read an API description before I read the tutorial associated with the API (or at least the tutorial for whatever higher-level concepts use the APIs). So I usually have a pretty good mental framework into which to plug the details. Perhaps this ties back into other things you said about why the tutorials weren't particularly helpful for you?
[toc] | [prev] | [next] | [standalone]
| From | bobwhite@mixnym.net |
|---|---|
| Date | 2012-10-29 19:09 +0000 |
| Message-ID | <uauyrnthsg.gvjmts@mixnym.net> |
| In reply to | #2193 |
> On 29/10/2012 7:07 AM, bobwhite@mixnym.net wrote: > >> On 26/10/2012 12:32 PM, Roedy Green wrote: > >>> On Fri, 26 Oct 2012 14:54:53 -0000, bobwhite@mixnym.net wrote, quoted > >>> or indirectly quoted someone who said : > >>> > >>>> I'm lost with > >>>> all the imports > >>> > >>> get an IDE that computes and maintains them for you automatically. See > >>> http://mindprod.com/jgloss/ide.html > >>> > >> > >> It seemed to me his problem was understanding something that depends on > >> a gazillion imports, not managing the imports themselves. > > > > Correct, thanks for reminding them! And more to the point, how to get a > > handle on this since Java is my first foray into a serious OO language. > > OK; it seems to me that if this thread is to help you we (or at least I) > need to understand how the large APIs you're used to manage to avoid > "zillions of imports" Monolithic APIs may be big but they're only one layer. That's really it, they're not OO APIs. It's easy because I don't have to understand any hierarchy because there isn't one. Clumsy but simple! > > On 26/10/2012 10:54 AM, bobwhite@mixnym.net wrote: > > I am used to very large APIs I don't that's it. I think one of > > the problems is the layering of things in Java and OO that I'm > > not used to. The APIs I'm using are self contained and don't > > build on other interfaces. I'm lost with all the imports and > > what you need to get this or that class that depends on > > zillions of other classes, or why they're needed. In my work > > all I need to do is pull in the right API and it doesn't need > > anything else. This is a big change in thinking. > > This seems like the right comment to focus on for me to understand your > problem. What kind of "large self-contained API" are you talking about? Imagine libc or syscalls. It's not it, but it's as close as I can come since I am working on a proprietary platform that is not widely known. > Can you give an example? For example, is it "large" in that it contains > very many methods or procedures, but those procedures take only > parameters of simple types like arrays and scalars? I think that's a good way to describe it. It has many different functions you can call but those functions take structures as arguments. > If so your problem isn't so much O-O specifically as the more basic idea > of abstract data types. I don't think that's true because I'm familiar with abstract data types. My confusion starts when I say gee let me read a string from the keyboard. Now where do I go from there? I look at the Java API doc and try to find something that looks like console IO. Ok, I see a function there, but now how do I use it? I have to set up exception handling before I can do that! How do I do that? And it goes downhill from there. > > And I don't think I understand how to read the API doc. I wish > > there were a guide to this specific issue. > > Hmm. Well, I rarely read an API description before I read the tutorial > associated with the API (or at least the tutorial for whatever > higher-level concepts use the APIs). So I usually have a pretty good > mental framework into which to plug the details. Perhaps this ties back > into other things you said about why the tutorials weren't particularly > helpful for you? It may be a chicken and egg thing that I just have to push through somehow.
[toc] | [prev] | [next] | [standalone]
| From | Patricia Shanahan <pats@acm.org> |
|---|---|
| Date | 2012-10-29 12:38 -0700 |
| Message-ID | <b9udnbXORYC9RhPNnZ2dnUVZ_tSdnZ2d@earthlink.com> |
| In reply to | #2194 |
On 10/29/2012 12:09 PM, bobwhite@mixnym.net wrote: ... > I don't think that's true because I'm familiar with abstract data types. My > confusion starts when I say gee let me read a string from the keyboard. Now > where do I go from there? I look at the Java API doc and try to find > something that looks like console IO. Ok, I see a function there, but now > how do I use it? I have to set up exception handling before I can do that! > How do I do that? And it goes downhill from there. ... Here's an alternative approach. I tried typing into Google "java console string read", without the quotes. The first few hits were each a tutorial with a sample program. I would read a few of them and look up some of the API features they use. They contain examples of using exception handling. In general, if you Google for the word "java" followed by what you want to do, you should get similar results. Patricia
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-10-29 13:42 -0700 |
| Message-ID | <6c8b5a13-cf9b-4a88-923a-07d01d4bccac@googlegroups.com> |
| In reply to | #2194 |
bobw...@ wrote: [attribution restored - bob, you need to attribute your quotes] David Lamb wrote: >> If so your problem isn't so much O-O specifically as the more basic idea >> of abstract data types. > > I don't think that's true because I'm familiar with abstract data types. My > confusion starts when I say gee let me read a string from the keyboard. Now Patricia gave you canonical advice for that. Also, so did everyone who pointed you to the tutorials: http://docs.oracle.com/javase/tutorial/essential/io/scanfor.html et seq. > where do I go from there? I look at the Java API doc and try to find > something that looks like console IO. Ok, I see a function there, but now > how do I use it? I have to set up exception handling before I can do that! http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html > How do I do that? And it goes downhill from there. Google "java <the function you found> tutorial". bobw...@ wrote: >>> And I don't think I understand how to read the API doc. I wish >>> there were a guide to this specific issue. http://lmgtfy.com/?q=Java+how+to+read+Javadocs+for+the+API >> Hmm. Well, I rarely read an API description before I read the tutorial >> associated with the API (or at least the tutorial for whatever >> higher-level concepts use the APIs). So I usually have a pretty good >> mental framework into which to plug the details. Perhaps this ties back >> into other things you said about why the tutorials weren't particularly >> helpful for you? > > It may be a chicken and egg thing that I just have to push through somehow. http://lmgtfy.com/?q=Java+how+to+read+Javadocs+for+the+API -- Lew
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-10-29 15:29 -0700 |
| Message-ID | <k6n017$pct$1@dont-email.me> |
| In reply to | #2194 |
On 10/29/2012 12:09 PM, bobwhite@mixnym.net wrote:
>
> I don't think that's true because I'm familiar with abstract data types. My
> confusion starts when I say gee let me read a string from the keyboard. Now
> where do I go from there? I look at the Java API doc and try to find
> something that looks like console IO. Ok, I see a function there, but now
> how do I use it? I have to set up exception handling before I can do that!
> How do I do that? And it goes downhill from there.
Some of this is just "time," like I mentioned before. Java has a BIG
API and you won't learn it well by just reading one thing. Getting a
few basic books and looking at how they do it will give you some ideas.
In other words, there's "patterns" here that work, and some that don't.
Also, the API is spread out. It's been improved incrementally for 17
odd years, and similar things are not all together. In general to read
user input you want the System, not Console. Console is recent and just
contains some extensions to the basic I/O that people were asking for.
System.in is the workhorse. Wrap that in a BufferedReader and read from
that.
Time and just plowing through will get you there after a while. The
important bit is to do it.
Here's the most basic method. Try to build on this, even if fancier
methods are available, until you get more familiar with the Java API and
things start to be easier. Note that for quick-and-dirty and testing I
think it's better to NOT catch the exception, just declare the main
method with " throws Exception" and let the system do its thing.
<http://www.mkyong.com/java/how-to-read-input-from-console-java/>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ReadConsoleSystem {
public static void main(String[] args) {
System.out.println("Enter something here : ");
try{
BufferedReader bufferRead = new BufferedReader(new
InputStreamReader(System.in));
String s = bufferRead.readLine();
System.out.println(s);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-10-31 07:28 -0700 |
| Message-ID | <q5d298hcfq1gmqcb1iai21ps7uh087ccdo@4ax.com> |
| In reply to | #2199 |
On Mon, 29 Oct 2012 15:29:57 -0700, markspace <-@.> wrote, quoted or indirectly quoted someone who said : >Also, the API is spread out. It's been improved incrementally for 17 >odd years, and similar things are not all together The other thing is Java is like a Lego set. Most of the pieces have to be combined in canonical ways to get the effects you want. How do you learn the idioms? To learn the conversion idioms (which fail from irregular naming and general inconsistency) see http://mindprod.com/applet/converter.html To learn the i/o idioms (except nio) see http://mindprod.com/applet/io.html -- Roedy Green Canadian Mind Products http://mindprod.com Let all things be done decently and in order. ~ I Corinthians 14:40. Apparently, Jehovah disapproves of Java Threads.
[toc] | [prev] | [next] | [standalone]
| From | bobwhite@mixnym.net |
|---|---|
| Date | 2012-11-03 20:37 +0000 |
| Message-ID | <nuvlmbcvcb.xvyaeh@mixnym.net> |
| In reply to | #2199 |
markspace said: > Some of this is just "time," like I mentioned before. Java has a BIG > API and you won't learn it well by just reading one thing. Getting a > few basic books and looking at how they do it will give you some ideas. > In other words, there's "patterns" here that work, and some that don't. Ok. > Also, the API is spread out. It's been improved incrementally for 17 > odd years, and similar things are not all together. In general to read > user input you want the System, not Console. Console is recent and just > contains some extensions to the basic I/O that people were asking for. > System.in is the workhorse. Wrap that in a BufferedReader and read from > that. Whaa?!? > Time and just plowing through will get you there after a while. The > important bit is to do it. I'm realizing this isn't going to be like learning another procedural or scripting language. I usually can write something meaningful in a new one of those the same day. > Here's the most basic method. Try to build on this, even if fancier > methods are available, until you get more familiar with the Java API and > things start to be easier. Note that for quick-and-dirty and testing I > think it's better to NOT catch the exception, just declare the main > method with " throws Exception" and let the system do its thing. snip Thanks for the link and code. I'd still like to find a book targeted to what I was asking about and especially an abstract explanation (no pun intended) of how to use the API doc but I'll go through the tutorials people recommended and see if I get anywhere this time. The Core Java books look good too! That will be the first one I try. Thanks to all. Bob
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-11-03 16:22 -0700 |
| Message-ID | <967d0bc8-7330-4673-b2d0-6f3f3c7eb075@googlegroups.com> |
| In reply to | #2220 |
bobw...@mixnym.net wrote:
> markspace said:
>> Some of this is just "time," like I mentioned before. Java has a BIG
>> API and you won't learn it well by just reading one thing. Getting a
>> few basic books and looking at how they do it will give you some ideas.
>> In other words, there's "patterns" here that work, and some that don't.
>
> Ok.
>
>> Also, the API is spread out. It's been improved incrementally for 17
>> odd years, and similar things are not all together. In general to read
>> user input you want the System, not Console. Console is recent and just
>> contains some extensions to the basic I/O that people were asking for.
>> System.in is the workhorse. Wrap that in a BufferedReader and read from
>> that.
>
> Whaa?!?
BufferReader reader = new BufferedReader(new InputStreamReader(System.in));
"To wrap" is one of the fundamental operations of computer programming.
>> Time and just plowing through will get you there after a while. The
>> important bit is to do it.
Well, to a point. You have got to gain a conversational fluency with the
terminology of computer programming. Otherwise "plowing through" risks seeing
the farm from the horse's viewpoint rather than the farmer's.
> I'm realizing this isn't going to be like learning another procedural or
> scripting language. I usually can write something meaningful in a new one of
> those the same day.
Java is a disciplined language, but actually is a procedural language.
Are you familiar with other compiled languages?
Java gives you building blocks, mostly through its API as the language itself
is reasonably spare.
You might want to wiki around for object-oriented thinking, but it can be
simply summarized for Java purposes as type thinking.
You construct types that interact, at best via the interface declarations with
no client knowledge of how a service implementation fulfills its promises.
You send and receive sensible types through those interfaces.
In this Java is pretty much like a lot of remote-programming protocols.
So get used to thinking of types that foment instances, and all with attributes
and behaviors.
Attributes are the 'T getX()' and 'setX(T x)' methods.
Behaviors are all the other methods.
Expressing attributes as getters and setters makes them annoying enough to
keep you from programming giant data-transfer types. That would be an
antipattern.
Generics are just base types and assertions about their relationships.
'Set<T>' means that you have a set each item of which is of type 'T'.
You can use generics for your own type, let's say an invoker of 'Invocable'
things.
public interface Invocable
{
/** Invoke this thing. */
void invoke();
}
/**
* Invoker of an {@code Invocable}.
* @param <T> base type to invoke.
*/
public class Invoker<T extends Invocable>
{
/**
* Invoke a base-type thing.
* @param invocable T proxied {@code Invocable}.
*/
public void invoke(T invocable)
{
invocable.invoke();
}
}
'<T extends Invocable>' asserts that 'T' defines an 'invoke()' method.
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-11-03 20:42 -0700 |
| Message-ID | <k74o6i$9lp$1@dont-email.me> |
| In reply to | #2221 |
On 11/3/2012 4:22 PM, Lew wrote: >> markspace said: >>> Console is recent and just >>> contains some extensions to the basic I/O that people were asking for. >>> System.in is the workhorse. Wrap that in a BufferedReader and read from >>> that. > bobw...@mixnym.net wrote: >> >> Whaa?!? > BufferReader reader = new BufferedReader(new InputStreamReader(System.in)); > > "To wrap" is one of the fundamental operations of computer programming. I hadn't even considered that. I thought he was complaining about the fact that I said the API was a bit spread out due to being extended for the past 17 years. The Wrapper Pattern isn't exactly fundamental to computer programming, but it is fundamental to object oriented programming, for certain. I'd recommend that Bob pick up a copy of Head First Design Patterns if he's unfamiliar with those concepts. Wrapper: <http://en.wikipedia.org/wiki/Adapter_pattern> Then pick up the Gang of Four book and read that. There's really no substitute for primary sources, even in computer science. Too many follow-on books are just pretenders and half-assed; always try to find the original article or source if at all possible.
[toc] | [prev] | [next] | [standalone]
| From | bobwhite@mixnym.net |
|---|---|
| Date | 2012-11-04 14:40 +0000 |
| Message-ID | <lluofnwxto.xeuifo@mixnym.net> |
| In reply to | #2222 |
Markspace said: > On 11/3/2012 4:22 PM, Lew wrote: > > >> markspace said: > >>> Console is recent and just > >>> contains some extensions to the basic I/O that people were asking for. > >>> System.in is the workhorse. Wrap that in a BufferedReader and read from > >>> that. > > > bobw...@mixnym.net wrote: > >> > >> Whaa?!? > > > > BufferReader reader = new BufferedReader(new InputStreamReader(System.in)); > > > > "To wrap" is one of the fundamental operations of computer programming. > > > I hadn't even considered that. I thought he was complaining about the > fact that I said the API was a bit spread out due to being extended for > the past 17 years. Yeah I understand what wrappering is and it has nothing to do with OO. I meant I was thinking about console stuff and then you come along and say to use BufferedReader and I have no idea what that is yet! > The Wrapper Pattern isn't exactly fundamental to computer programming, > but it is fundamental to object oriented programming, for certain. I have been wrappering before Java or C++ ever existed. I won't say before Simula since that was before my time. Wrappering is an interfacing concept, it's not an OO concept, but I can see how OO would use it, obviously. > I'd recommend that Bob pick up a copy of Head First Design Patterns if > he's unfamiliar with those concepts. > > Wrapper: <http://en.wikipedia.org/wiki/Adapter_pattern> That page has alot of stuff I haven't seen before with those names. The details probably don't matter but the structure is something I know about it. > Then pick up the Gang of Four book and read that. I will keep that on the list for later after I get the idea of the core language. > There's really no substitute for primary sources, even in computer > science. Too many follow-on books are just pretenders and half-assed; > always try to find the original article or source if at all possible. I agree with that in most cases. There have been some good things invented by people who weren't very good at explaining them, but mostly from the horses mouth is the way to go. Bob
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.java.help
csiph-web