• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

API more common methods

 
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear coders,

as beginner can easy find on internet some tutorials that explain what are the most common methods i can implement
but I have to go through several tutorials and spend a lot of time every time
maybe ..
there is a way I can go inside an APIin sites like oracle or grepcode and select ONLY the more common methods?

ex.
http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html

if I use Integer, I want to see between the first ten parseInt(String s) and not other 18 ones.
then if I look for something less common, of course I will look up a tutorial and I will go through all the class.

thanks

 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a beginner, I assume you are using a text editor and compiling at the command line. This is good for now. I would advise you to continue looking up methods if you have to. This will help you memorise them. (I don't know of a way to look at the API JavaDocs for only "popular" methods.)

When you start using an IDE to program in, most will have a way of looking for available methods. In Eclipse it's Ctrl-Space. You will still see all the methods, but you will be able to easily pick up which one is the best to use, and Eclipse (and others?) will suggest the most likely method based on the context of your code.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I don't think there is a list of commonly used and rarely used methods in the API.

By the way: if you are using the Integer class, beware of getInteger. It has a very misleading name.
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:No, I don't think there is a list of commonly used and rarely used methods in the API.

By the way: if you are using the Integer class, beware of getInteger. It has a very misleading name.



thanks Ritchie let s share with the java wannabe of the ranch for future reference
http://stackoverflow.com/questions/3123349/why-does-int-num-integer-getinteger123-throw-nullpointerexception

regarding the other friend, paradoxicaly. am using eclipse no compiler from the command line, eclipse is more easy as immediately correct my mistakes and suggests what I miss apart the dynamic mistakes at runtime

by the way there is a tool that shows all my command from a reflection point of view so that I can see how the compiler interpret them and understand better how API consequently work?

I mean it would help me to know that instead of the first the compiler uses the second expressions( this reflection stuff makes me salivate)
[JAVA]
// without reflection
Foo foo = new Foo();
foo.hello();

// with reflection
Object foo = Class.forName("complete.classpath.and.Foo").newInstance();
// Alternatively: Object foo = Foo.class.newInstance();
Method m = foo.getClass().getDeclaredMethod("hello", new Class<?>[0]);
m.invoke(foo);
[/JAVA]

 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may find some of the commoner methods for some classes in the Java Tutorials.
That was a good discussion you found on SO.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Giovanni Montano wrote:there is a way I can go inside an APIin sites like oracle or grepcode and select ONLY the more common methods?


What determines if a method is a common method or not a common method? I think that's a matter of opinion and there is no clear, objective way to determine this.
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:You may find some of the commoner methods for some classes in the Java Tutorials.
That was a good discussion you found on SO.


grazie sherif
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:

Giovanni Montano wrote:there is a way I can go inside an APIin sites like oracle or grepcode and select ONLY the more common methods?


What determines if a method is a common method or not a common method? I think that's a matter of opinion and there is no clear, objective way to determine this.


Jesper, I think it depends by the context, you can be for the feynord ( if LinkedIn is exact) but still probably in these days you say hup Hollande;)

so for sure there is a smaller knowledge that users that start to learn need to get familiar, a newbie like me will start to learn sysout.println more easily but from a bigger point of view an expert could start to need for instance system.runFinalizerOnExit.

so all in all Netherlands can play well or not but ...as Ajax Cruijf teaches( and my boss) || ( elke nadeel is een voordeel) every negative aspect has some advantages, learning the more statistical used classes makes me more fast a junior programmer ;)
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest reflection is a very bad way to find methods in a class. The documentation is where you should go.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Giovanni Montano wrote:learning the more statistical used classes makes me more fast a junior programmer


I think I understand what you're saying, and I sympathise; but there is a danger in this sort of "cherry-picking" - namely: you don't get the whole picture of a class, and you may make mistakes as a result.

However, even the designers of Java aren't perfect; and there are several examples - especially in the Collections Framework (List being a classic one) - where classes have been "over-engneered", making them daunting for beginners like yourself.

Even String is arguably "overdone"; and I doubt if I've ever used even half of the 71 methods or 16 constructors it offers. However, it IS probably the most "commonly" used class in Java, so it's worth getting to know its API very well.

My advice: Start with the methods defined in Object - specifically: equals(), hashCode() and toString(); and whenever you look up a new class API, make sure you understand (a) whether the class overrides them, and (b) if so, how they work for that class.

The rest you can probably get by osmosis. Whenever you need to do something with a new class:
1. Read the class documentation thoroughly.
2. If it implements an interface, read its documentation as well.
3. Search for the method that looks closest to what you want to do. If you find an exact match, you can probably stop; but it's far more likely that you'll find one that comes close - and in that case, keep going to see if there are any others that come closer.
String, for example, has at least 5 different methods for searching, and 4 for replacement, so don't simply take the first one you find.

The rest will come with familiarity and practise. Promise.

HIH

Winston
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Giovanni Montano wrote:Jesper, I think it depends by the context, you can be for the feynord ( if LinkedIn is exact) but still probably in these days you say hup Hollande;)


I'm not a big soccer fan but I do watch the world championship
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:
The rest will come with familiarity and practise. Promise.

HIH

Winston


Dear Winston, thank you for your reply.
familiarity and practice are indeed two pillars, and are even interrelated.
in one sentence: learning by doing.
When a problem occurs find a solution and go to the next step.
More time you spend on one task more you will remember after.


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic