Home > Archive > Java Help > January 2007 > Is there an easy way to find the right class?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Is there an easy way to find the right class?
|
|
| Farcus Pottysquirt 2007-01-29, 7:07 pm |
| The API has tons of classes and stuff right? So if I'm writing a
program in Java, how would I find the right class and package? Let's
say I'm writing an app and I need a class that will take a database
object and store it in some sort of list that will let me easily add and
delete from it. I know that ArrayList has this functionality...but
that's only by experience. What about a noobie (I rank myself only
slightly higher)... how would they find this out?
| |
| Corona4456 2007-01-29, 7:07 pm |
|
On Jan 29, 3:53 pm, Farcus Pottysquirt <where_is_my_...@movies.net>
wrote:
> The API has tons of classes and stuff right? So if I'm writing a
> program in Java, how would I find the right class and package? Let's
> say I'm writing an app and I need a class that will take a database
> object and store it in some sort of list that will let me easily add and
> delete from it. I know that ArrayList has this functionality...but
> that's only by experience. What about a noobie (I rank myself only
> slightly higher)... how would they find this out?
Java is well documented at <http://java.sun.com/j2se/1.5.0/docs/api/
index.html>.
Using Eclipse helps out a lot. Google eclipse and you'll find it. It
is an excellent
IDE for java.
| |
| Corona4456 2007-01-29, 7:07 pm |
|
On Jan 29, 5:28 pm, "Corona4456" <robertsa...@gmail.com> wrote:
> On Jan 29, 3:53 pm, Farcus Pottysquirt <where_is_my_...@movies.net>
> wrote:
>
> index.html>.
> Using Eclipse helps out a lot. Google eclipse and you'll find it. It
> is an excellent
> IDE for java.
Weird... I'll try this again:
<http://java.sun.com/j2se/1.5.0/docs/api/index.html>
| |
| Farcus Pottysquirt 2007-01-29, 7:07 pm |
| Corona4456 wrote:
>
> On Jan 29, 5:28 pm, "Corona4456" <robertsa...@gmail.com> wrote:
>
> Weird... I'll try this again:
> <http://java.sun.com/j2se/1.5.0/docs/api/index.html>
>
I use Eclipse and Netbeans as my IDE's so I am familiar with them. I
enjoy the fact that both IDE's attempt to provide suggestions as to what
I am trying to do...but what if I was sitting down with only a pad of
paper, a pencil (with an eraser) and a reference like Java In a Nutshell
(O'Reilly) how would I find the class/package I need without looking at
each and every one until I find it? There must be an easier way.
Internet access makes it somewhat easier, but even Google provides more
information than I need. See what I mean. Let's ask someone like
Andrew Thompson... hey .... how do you find a class that you need? Do
you have a website you consult or some other book?
| |
|
|
| Andrew Thompson 2007-01-29, 10:06 pm |
| On Jan 30, 11:37 am, Farcus Pottysquirt <where_is_my_...@movies.net>
wrote:
> ..There must be an easier way.
> Internet access makes it somewhat easier, but even Google provides more
> information than I need. ...
*
>...Let's ask someone like
> Andrew Thompson... hey .... how do you find a class that you need?
I am not quite sure why my name came up in this
thread, but FTR, my search would be in this order..
1) JavaDocs (first looking at the descriptions of any
classes that I feel should be closely related, then
having a look at other classes in the packages in
which they reside).
2) Java Tutorial - skimming any section that looks
like it might be relevant.
3) Searching the comp.lang.java.* groups, and when
I get *'too much' information, refining the search, or
looking at the 'most recent' posts first.
4) Searching the net, and when I get
*'too much' information, refining the search.
5) Asking hereabouts for advice (mentioning
the unsuccessful search terms).
Note that in the early stages, I found it was
better to swap the search order of JDocs and
the Java Tutorial.
Andrew T.
| |
| Patricia Shanahan 2007-01-30, 8:09 am |
| Farcus Pottysquirt wrote:
> The API has tons of classes and stuff right? So if I'm writing a
> program in Java, how would I find the right class and package? Let's
> say I'm writing an app and I need a class that will take a database
> object and store it in some sort of list that will let me easily add and
> delete from it. I know that ArrayList has this functionality...but
> that's only by experience. What about a noobie (I rank myself only
> slightly higher)... how would they find this out?
If I have any clues about the package I want, I go straight to the API
documentation, and start reading about that package. In particular, read
any package page in the documentation - it often gives major clues about
which classes to use in what situations.
If not, I google:
java whatever
where "whatever" is a description of what I want to do.
Patricia
| |
| Patricia Shanahan 2007-01-30, 8:09 am |
| Farcus Pottysquirt wrote:
....
> I use Eclipse and Netbeans as my IDE's so I am familiar with them. I
> enjoy the fact that both IDE's attempt to provide suggestions as to what
> I am trying to do...but what if I was sitting down with only a pad of
> paper, a pencil (with an eraser) and a reference like Java In a Nutshell
> (O'Reilly) how would I find the class/package I need without looking at
> each and every one until I find it?
I have programmed with a pad of paper, a pencil, an eraser, and a paper
reference. I worked that way for several years - in the 1970's. The
languages were much simpler, so I could read the complete documentation,
and the paper book could tell me everything I needed to know, not just a
useless summary.
Why on earth would anyone be programming that way in the twenty-first
century, in a language with a rich API and a lot of additional packages
that can be downloaded?
Patricia
| |
| Farcus Pottysquirt 2007-01-30, 7:11 pm |
|
> Why on earth would anyone be programming that way in the twenty-first
> century, in a language with a rich API and a lot of additional packages
> that can be downloaded?
>
> Patricia
What if you're on a long flight and don't have your laptop and wireless
access and come up with a great idea for the next killer app? You want to
come up with something, and since your flight to...ohh...say... Melbourne
from NYC is 12 hrs you've got time to kill.
| |
| chris1980 2007-01-30, 7:11 pm |
| well what i will suggest you rite now is that forget about the Api.
take a pencil and a paper and skecth the design what you need to do. I
had the same problem back 4 months ago and yes i am still a newbie but
not very new. so i suggest you to write a program just a simple
program then say for instance if you are using
String name;
Now lets assume if you want to change all the letters entered by the
user to uppercase. you can go to the Api docs and you can check the
method string.uppercase()
in your case it would be name.toUppercase(). i hope you are getting
the idea what i am trying to say. now if you would like to use Arrays.
you should import java.util.Arrays; and then you can use alot of
arrays method define in Api for your programs like for eg if you want
to sort the whole array. you can do.
for(int i=0; i<data.length; i++)
Arrays.sort();
hope this helps.
Thanks
| |
| Farcus Pottysquirt 2007-01-30, 7:11 pm |
| I think you are on to something here. If I am looking to do something with
an integer, I would look at the API or another reference book...fine... no
issues here. But what if I am trying to find out how to read a sequential
file? I know the API has classes for it (I'm looking at them now) but what
if I don't know where in the API to look? Is it safe to assume that
something to do with files, would be in the java.io package? Is it possible
that something better exists in another package? Of course, this is
assuming that I have the API either online or downloaded on my local pc. or
a really good book to consult. By identifying the "type" of object I want
to operate on, I should be able to narrow the search down and then consult a
reference....
thanks...that helped me a whole lot
| |
| RedGrittyBrick 2007-01-30, 7:11 pm |
| Farcus Pottysquirt wrote:
> what if I was sitting down with only a pad of
> paper, a pencil (with an eraser) and a reference like Java In a Nutshell
> (O'Reilly) how would I find the class/package I need without looking at
> each and every one until I find it?
Most books have a Contents section at the front and an index at the
back. I'd look in the Contents section for topics that seem close to
what I needed. If that didn't work I'd dream up a few likely keywords
and look for them in the index.
Google is useful though.
Of course, the above are obvious to you already. Since you are not a
member of the secret cabal, we're not telling you of the far superior
secret method that you suspect exists.
Actually, for your problem as stated, a random walk algorithm should be
quite good, the problem probably correlates quite well with some recent
scientific research into food-gathering methods employed by various
animals and hunter-gatherer tribes in a pre-agricultural setting. An
occasional long distance relocation followed by a series of small random
movements is apparently quite effective in simulations. I recommend that
over a simple linear traversal of the search space.
| |
|
|
| Farcus Pottysquirt 2007-01-30, 7:11 pm |
| RedGrittyBrick wrote:
>
> Most books have a Contents section at the front and an index at the
> back. I'd look in the Contents section for topics that seem close to
> what I needed. If that didn't work I'd dream up a few likely keywords
> and look for them in the index.
Yes... live the dream...I think that if you are forced to resort to
using a book (maybe because you are on a desert island) then you need
something high level to start looking for and then narrow you search.
> Google is useful though.
Only if you format your search properly. Otherwise you can end up with
pages and pages of stuff that looks useful on the summary page, but once
you get in there, it's talking about C++ or PHP or ... gasp ... COBOL
>
> Of course, the above are obvious to you already. Since you are not a
> member of the secret cabal, we're not telling you of the far superior
> secret method that you suspect exists.
>
I knew it.... the dirty dozen rides again...how do I join? Are
Canadians welcome?
> Actually, for your problem as stated, a random walk algorithm should be
> quite good, the problem probably correlates quite well with some recent
> scientific research into food-gathering methods employed by various
> animals and hunter-gatherer tribes in a pre-agricultural setting. An
> occasional long distance relocation followed by a series of small random
> movements is apparently quite effective in simulations. I recommend that
> over a simple linear traversal of the search space.
I have no idea what you just said ... Are you calling me a Neanderthal?
I assure you ... my arms may be long, and my love for bananas
legendary, but I am not a gorilla LOL.
Seriously though, if the Internet (thunderbird flagged internet as a
spelling mistake and I don't want to make spelling mistakes no more) is
such a great source of information, why isn't there a site (like off the
sun site) where you can go and type in a class criteria search and have
it return some useful classes?
FP ...
| |
| Farcus Pottysquirt 2007-01-30, 7:11 pm |
| Andrew Thompson wrote:
> I am not quite sure why my name came up in this
> thread, but FTR, my search would be in this order..
>
FTR= For The Record?
It's a show of respect to ask someone more knowledgeable...
> 1) JavaDocs (first looking at the descriptions of any
> classes that I feel should be closely related, then
> having a look at other classes in the packages in
> which they reside).
feel based on what? experience? what about someone with little (like
me) or no experience?
>
> 2) Java Tutorial - skimming any section that looks
> like it might be relevant.
doesn't give enough details...
>
> 3) Searching the comp.lang.java.* groups, and when
> I get *'too much' information, refining the search, or
> looking at the 'most recent' posts first.
>
* good idea.. but what do you search for?
> 4) Searching the net, and when I get
> *'too much' information, refining the search.
>
see above *
> 5) Asking hereabouts for advice (mentioning
> the unsuccessful search terms).
>
gotta make sure that I show my work before asking the question :-)
> Note that in the early stages, I found it was
> better to swap the search order of JDocs and
> the Java Tutorial.
>
> Andrew T.
>
Good idea....
| |
| Farcus Pottysquirt 2007-01-30, 7:11 pm |
| Lew wrote:
> This is a Zen question.
Yes but can it help me maintain my motorcycle better.
> The short answer is that you simply have to know the API. That means a
> lot of time constantly studying a moving target.
Any recommendations on how you would accomplish this?
> The tutorials help, with a few packages like the Collections framework.
> <http://java.sun.com/docs/books/tuto...ions/index.html>
> (Written by Josh Bloch!)
You mean the guy who wrote _Essential Java_ ?
> Or in depth tutorials like
> <http://java.sun.com/developer/onlin...ing/essentials/>
Looked there... 2003? So I guess jdk1.6 isn't being looked at yet?
> Aside from that I recommend studying the API package by package.
> Here's a good place for studying java.util.
> <http://java.sun.com/j2se/1.5.0/docs...ge-summary.html>
Do each of the packages have a page like this?
Looks like java/io does at least
> You can go a long time knowing only a subset. For example, I am only now
> finally after forever getting around to studying the NIO packages.
> <http://java.sun.com/javase/6/docs/a...age_description>
Did you have a particular reason to study the NIO packages? If so, was
it because you found out that the NIO package has a class that your app
can use? And how do you know which package to study? Did you ask
someone like I'm asking the group now?
> <http://java.sun.com/javase/6/docs/a...age_description>
> GIYF.
GIYF??? - ... ahhh... google is your friend
| |
| Patricia Shanahan 2007-01-30, 7:11 pm |
| Farcus Pottysquirt wrote:
> Patricia Shanahan wrote:
>
>
>
> But wouldn't it be great if there was a database or website where you
> could go and type in "what class for reading a text file" and the
> site/DB would return a list of classes for me to investigate.
The fewer words that do not directly relate to the objective, the
better. For that query, I would use:
java read text file
Of course, you still have to apply your own judgement to the results. I
would go with http://java.sun.com/docs/books/tutorial/essential/io/,
which was the fourth result, but is a Sun tutorial covering the subject.
That is likely to be far more useful, for someone who does not know what
class to use, than a mere list of classes.
Patricia
| |
|
| Lew wrote:
Farcus Pottysquirt wrote:[color=darkred]
> You mean the guy who wrote _Essential Java_ ?
Yes. Read everything by him that you can.
[color=darkred]
> Looked there... 2003? So I guess jdk1.6 isn't being looked at yet?
These may be old but they still work. There are other resources for newer
packages.
[color=darkred]
> Do each of the packages have a page like this?
Pretty much.
[color=darkred]
> Did you have a particular reason to study the NIO packages?
Only because it was way old and I didn't know it yet.
> If so, was it because you found out that the NIO package has a class that your app can use?
Nope. But now that I am learning about it, actually them, I see all kinds of
usefulness.
> And how do you know which package to study?
All of them.
> Did you ask someone like I'm asking the group now?
I did not. I study all of them. I haven't finished yet, and there remain many
packages I have not yet started on.
Sometimes a project will have me learn something, as when I was first tasked
with designing and implementing a Web service using SOAP.
I'd say that java.lang, java.util (and related) and java.io/java.nio (and
related) are the most important to learn first. For Web apps know the servlet
APIs and how to use JSP, JSTL and EL. Know about generics, threading and a few
dozen useful patterns. Read the white papers, such as the theoretical
underpinnings of the Java synchronization (Hoare monitors). Learn about things
that Java doesn't support (e.g., function closures), and what Java has instead
(functor classes).
In other words, I do not see any easy ways. Is there an easy way to be a
concert violinist?
> GIYF??? - ... ahhh... google is your friend
Tourist in New York City:
"Can you tell me how to get to Carnegie Hall?"
Manhattanite:
"Practice, practice, practice!"
- Lew
- Lew
|
|
|
|
|